#include #include #define INVALID { printf("invalid\n"); continue;} int main() { char s[50]; unsigned long long int yr, mth, dy, gb, check; int len; unsigned int i; do { scanf("%s", s); if (strcmp(s, "end") == 0) break; len = strlen(s); if (strlen(s) > 11 || strlen(s) < 10) INVALID for (i=0;i '9')) INVALID } sscanf(s + 7, "%Lu", &check); s[6] = 0; sscanf(s + 4, "%Lu", &dy); s[4] = 0; sscanf(s + 2, "%Lu", &mth); s[2] = 0; sscanf(s, "%Lu", &yr); if (yr < 20 && yr > 9) INVALID if (yr < 54 && yr > 9 && len == 11) INVALID if (yr < 54 && yr > 9 && len == 10) check *= 10; if ((yr > 53 || yr <= 9) && len == 10) INVALID if (mth > 12 && mth < 51) INVALID if (mth > 62) INVALID if (mth == 0) INVALID if (mth > 50) gb = 1; else gb = 0; switch((mth > 50) ? (mth - 50) : mth) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (dy > 31 || dy == 0) INVALID break; case 4: case 6: case 9: case 11: if (dy > 30 || dy == 0) INVALID break; case 2: if ((yr % 4) && dy > 28) INVALID else if (dy > 29) INVALID if (dy == 0) INVALID break; default: INVALID } if (len == 11) if ( ( ((yr * 100 + mth) * 100 + dy) * 10000 + check ) % 11 ) INVALID if (gb) printf("girl\n"); else printf("boy\n"); } while(1); return 0; }