Personal code

These days most countries assign each of the citizens a unique identifier, which we shall call personal code.
In Lithuania, personal code consists of eleven digits, and is assigned according to these rules:
- First digit denotes gender altogether with century of birth. Even numbers are assigned to females, odd to males. Centuries are numbered ascending. For example, “1” is for males born in 19th century whereas “4” is used for females born in 20th century.
- Second and third digits denote birth year in previously determined century.
- Fourth and fifth digits denote month of birth.
- Sixth and seventh digits denote day of birth.
- Eighth, ninth and tenth digits are assigned consecutively.
- Eleventh digit is for checksum. The sum is first calculated:
X1+2∙X2+…+9∙X9+X10
If this sum, when divided by 11, does not produce 10 as remainder, we have found the checksum. Otherwise, sum is recalculated:
3∙X1+4∙X2+…+9∙X7+X8+…+3∙X10
Again, if remainder is not 10, then we have found checksum. Else, we take 0 as the checksum.
Your task is to validate a personal code. Provided on the input file is eleven-digit code. You shall print to the output file OK if a living person could have given code, or FAIL otherwise. For this task, you can assume that humans live forever. An example is presented below.
| Input |
Output |
Comment |
| 38703181745 |
OK |
Valid code. |
| 38703181746 |
FAIL |
Invalid checksum. |
| 78703181745 |
FAIL |
Birth year would be 2100 + 87 = 2187. That is future. |
| 38703421745 |
FAIL |
March has less than 42 days. |