#include #include #include using namespace std; int main() { while(1) { string line; getline(cin, line); if(line == "end") break; if(line.length() != 10 && line.length() != 11) { cout << "invalid" << endl; continue; } if(line[6] != '/') { cout << "invalid" << endl; continue; } int year = 0; int month = 0; int day = 0; long long number = 0; bool boy = true; bool threeDigs = false; year = (line[0] - '0') * 10 + (line[1] - '0'); month = (line[0+2] - '0') * 10 + (line[1+2] - '0'); day = (line[0+4] - '0') * 10 + (line[1+4] - '0'); string num = line.substr(0, 6); if(line.substr(7).length() == 3) { num += "0"; threeDigs = true; } num += line.substr(7); istringstream numStream(num); numStream >> number; if(number % 11 != 0) { cout << "invalid" << endl; continue; } if(year >= 54 || year <= 9) { if(threeDigs) { cout << "invalid" << endl; continue; } } else { if(!threeDigs) { cout << "invalid" << endl; continue; } } if(year > 9 && year < 20) { cout << "invalid" << endl; continue; } if(month >= 50) { boy = false; month -= 50; } if(month > 12 || month <= 0) { cout << "invalid" << endl; continue; } int maxDays; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: // 31 dni v mesici if(day > 31 || day == 0) { cout << "invalid" << endl; continue; } break; case 2: // unor maxDays = 28; if(year % 4 == 0) maxDays = 29; if(day > maxDays || day == 0) { cout << "invalid" << endl; continue; } break; default: // 30 dni v mesici if(day > 30 || day == 0) { cout << "invalid" << endl; continue; } break; } if(boy) cout << "boy" << endl; else cout << "girl" << endl; } return 0 ; }