#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define FOR2(i,a,b) for (int i = (a); i > (b); ++i) /* #define FOR(i,n) for(int i=0; i < (n); i++) #define FORD(i,n) for(int i=(n)-1; i >= 0; i--) #define FORTO(i,a,b) for (int i = (a); i <= (b); ++i) */ #define DEBUG(x) cout << '>' << #x << ' ' << x << endl; #define SIZE(x) int(x.size()) typedef pair PII; typedef long long ll; char input[47]; int len; const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31}; int leap(int year) { if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) return 1; return 0; } int ds(int month, int year) { if (month != 2) return days[month-1]; return days[month-1]+leap(year); } bool check(bool & girl) { //najde slash int sl = -1; FOR(i, 0, len) if (input[i] == '/') { if (sl == -1) sl = i; else return false; } if (sl != 6) return false; int year = (input[0]-'0')*10 + input[1]-'0', month = (input[2]-'0')*10 + input[3]-'0', day = (input[4]-'0')*10 + input[5]-'0'; //nastavi rok if (year >= 20) year += 1900; else if (year <= 9) year += 2000; else return false; if (month >= 50) { girl = true; month -= 50; } else girl = false; if (month < 1 || month > 12 || day < 1) return false; if (ds(month, year) < day) return false; //3 cisla za if (year <= 1953 && len-sl-1 != 3) return false; //4 cisla za if (year >= 1954 && len-sl-1 != 4) return false; //cekne delitelnost ll n = 0; FOR(i, 0, len) if (isdigit(input[i])) n = n*10 + input[i]-'0'; if (len == 10) return true; return (n % 11 == 0); } int main() { while (1) { gets(input); if (input[0] == 'e') break; len = strlen(input); bool girl; if (!check(girl)) printf("invalid\n"); else { if (girl) printf("girl\n"); else printf("boy\n"); } } return 0; }