Intriguing Identifiers
InterviewTime limit1sMemory limit256 MB
Validate each given identifier as a Czech Personal ID for a birth between 1920 and 2009, and report the gender or mark it invalid.
- Level
Medium4 of 10
- Topics
- Implementation, String, Math, Number theory
- Solved
- No attempts yet
Problem
Corruptionists often use fictional persons to camouflage their illegal activities. They create fake database records containing non-existing names, addresses, or even personal identifiers. The ACM would like to fight against such practices. They are going to examine several suspicious databases and search them for invalid records. Can you help them by checking the validity of Personal IDs?
(Please note: in reality, some of the facts stated below may not always hold, and in exceptional cases some identifiers may violate them. However, for the purpose of this problem, we assume an ideal world without any such exceptions.)
A Personal ID (also known as rodné číslo, or simply RČ) is a unique identifier of a Czech (or Slovak) citizen. It is assigned once a child is born and remains unchanged for their whole life.
The identifier has two numerical parts separated by a single slash character (/). The first part always consists of exactly six digits and represents the birth date of the person in the form YYMMDD: the first two digits specify the year (modulo 100), the next two digits the month (01–12), and the last two digits the day of the month (01–31, but some months have fewer days). Besides the birth date, this part also encodes the gender: for all girls the month number is increased by 50. Thus, for example, 61 means November for a girl.
The second part has either 3 or 4 digits (all of them may be zero). For all identifiers assigned up to December 31, 1953, there were only three digits. Starting from January 1, 1954, every child is assigned an ID with exactly four digits after the slash. The additional digit allows a simple automated check: if we remove the slash, the whole ten-digit number must be divisible by 11.
Input
Each line of the input contains one string consisting of at least 1 and at most 20 characters, each of which is either a digit or a slash (/). The word end follows the last string.
Output
For each string, output the word invalid if the given string does not represent a valid Personal ID of a person born between January 1, 1920 and December 31, 2009, inclusive.
For valid identifiers, print either girl or boy, depending on the gender of the child who could be assigned that ID.