#include #include using namespace std ; int main() { string line ; unsigned int i ; bool male ; int y, m, d, r, ty ; c1: while (getline(cin, line) && (line != "end")) { male = true; if (line.length() != 10 && line.length() != 11) { cout << "invalid" << endl ; continue ; } for (i = 0 ; i < line.length() ; i++) { if (i == 6) { if (line[i] != '/') { cout << "invalid" << endl ; goto c1 ; } } else if (line[i] == '/') { cout << "invalid" << endl ; goto c1 ; } } i = 0 ; ty = y = (line[0] - '0') * 10 + (line[1] - '0') ; m = (line[2] - '0') * 10 + (line[3] - '0') ; d = (line[4] - '0') * 10 + (line[5] - '0') ; if (line.length() == 10) { if (y >= 54 || y < 20) { cout << "invalid" << endl ; continue ; } y = 19 * 100 + y ; r = (line[7] - '0') * 100 + (line[8] - '0') * 10 + (line[9] - '0') ; //check = y * 10000000 + m * 100000 + d * 1000 + r ; } else { if (y < 54 && y > 9) { cout << "invalid" << endl ; continue ; } else if (y < 54 && y > 8) y = 1900 + y ; else y = 2000 + y ; r = (line[7] - '0') * 1000 + (line[8] - '0') * 100 + (line[9] - '0') * 10 + (line[10] - '0') ; if ((((((ty % 11) * 100 + m) % 11) * 100 + d) % 11 * 10000 + r) % 11 != 0) { cout << "invalid" << endl ; continue ; } } if (m > 50) { m -= 50 ; male = false ; } switch (m) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (d < 1 || d > 31) { cout << "invalid" << endl ; continue ; } break ; case 4: case 6: case 9: case 11: if (d < 1 || d > 30) { cout << "invalid" << endl ; continue ; } break ; case 2: if (d < 1 || d > 28 + ((y % 4 == 0 && (y % 100 != 0 || y % 1000 == 0)))) { cout << "invalid" << endl ; continue ; } break ; default: cout << "invalid" << endl ; continue ; } cout << (male ? "boy" : "girl") << endl ; } return 0 ; }