#include #include using namespace std; int vrat_den(int a, int b){ switch(a){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; break; case 4: case 6: case 9: case 11: return 30; break; case 2: if(b % 4 == 0) return 29; else return 28; break; } } bool vrat_cislo(char * pole){ int pom,par,nep; bool vrat; par = nep = 0; for(int i=0; i<6; i++){ pom = (int)pole[i]; pom -= 48; if(i%2 == 0){ par += pom; } else{ nep += pom; } } //cout << "par: " << par << endl; //cout << "nep: " << nep << endl; if(strlen(pole)==10){ pom = (int)pole[9]; pom -= 48; nep += pom; pom = (int)pole[7]; pom -= 48; nep += pom; pom = (int)pole[8]; pom -= 48; par += pom; } else{ for(int i=0; i<4; i++){ pom = (int)pole[10-i]; pom -= 48; if(i%2 == 0){ nep += pom; } else{ par += pom; } } } //cout << "Par: " << par << endl; //cout << "Nep: " << nep << endl; if((nep-par)==0 || (((nep-par)%11)==0)){ vrat = true; } else{ vrat = false; } //cout << (int)vrat << endl; return vrat; } int main(){ char str[12]; int a,b,c,rok,mesiac,den; bool is_boy; while(cin >> str && str[0]!='e'){ is_boy = false; a =(int)str[0]; c =(int)str[1]; a -= 48; c -= 48; a = (a*10)+c; rok = a; //cout << str[0] << " " << a << " /" << endl; //if(a>=2 || a==0){ if(rok<=9 || rok>=20){ if(a!=1){ b =(int)str[2]; c =(int)str[3]; b -= 48; c -= 48; b = (b*10)+c; //cout << b << endl; if((b>=1 && b<=12) || ((b-50)>=1 && (b-50)<=12)){ if(b>=1 && b<=12){ // cout << "tr" << endl; is_boy = true; } else{ is_boy = false; } //is_invalid = false; mesiac = b; b =(int)str[4]; c =(int)str[5]; b -= 48; c -= 48; b = (b*10)+c; if(rok<=9) den = vrat_den(mesiac,(2000+rok)); else den = vrat_den(mesiac,(1900+rok)); // cout << "den is: " << den << endl; if(b>=1 && b<= den){ if(vrat_cislo(str)==true){ if(is_boy==true){ cout << "boy" << endl; } else{ cout << "girl" << endl; } } else{ cout << "invalid" << endl; } } else{ cout << "invalid" << endl; } } else{ cout << "invalid" << endl; } } else{ cout << "invalid" << endl; } } else{ cout << "invalid" << endl; } } return 0; }