#include #include char line[1000]; int mnt[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; bool is(char c) { return (c>='0' && c<='9'); } int main() { #define end {printf("invalid\n");continue;} while(1) { fgets(line, 100, stdin); line[strlen(line)-1]=0; if (!strcmp(line, "end")) return 0; int len = strlen(line); if (len>11 || len <10) { printf("invalid\n"); continue; } int Y = 0; int M=0; if (!(is(line[0]) && is(line[1]))) end else { Y=(line[0]-'0')*10+(line[1]-'0'); } //printf("Y %d %c %c", Y, line[0], line[1]); if (Y>=10&&Y<20) end; if (!(is(line[2]) && is(line[3]))) end else { M=(line[2]-'0')*10+(line[3]-'0'); } bool boy=true; if (M>50) { M-=50; boy=false; } if (M<=0 || M>12) end; int D; if (!(is(line[4]) && is(line[5]))) end else { D=(line[4]-'0')*10+(line[5]-'0'); } //printf("<%d %d>", M, D); if ((Y==0 || (Y % 4)==0) &&M==2) { if (D<=0 || D>29) end } else if (D<=0 || D>mnt[M]) end if (line[6]!='/') end int beh=0; if ((is(line[7]) && is(line[8]) && is(line[9]) && is(line[10]) && len==11 && ((Y<20)||(Y>53)))) { for (int j=7; j<11; j++) beh= beh*10 + line[j]-'0'; } else if ((is(line[7]) && is(line[8]) && is(line[9]) && len==10 && ((Y>=20)&&(Y<54)))) { for (int j=7; j<10; j++) beh= beh*10 + line[j]-'0'; } else end long long vysl = 0; if (len==11 && boy) { vysl = (long long)Y*100000000 + M*1000000 + D*10000+beh; if (vysl%11) end }else if (len==11) { vysl = (long long)Y*100000000 + (M+50)*1000000 + D*10000+beh; if (vysl%11) end } if (boy) printf("boy\n"); else printf("girl\n"); } return 0; }