Fiscal Identification Number (FIN) P24216


Statement
 

pdf   zip

html

The Fiscal Identification Number (NIF in Spanish) is a unique code that identifies to the Spanish citizens. NIF is a eight-figure number (that form the National Document of Identity or DNI in Spanish) with a control letter that is obtained from the number of DNI. This letter is used to verify that the NIF has been correctly introduced. To obtained the NIF letter, DNI modulo 23 must be computed. The result, a number between 0 and 22, is converted into a letter according to the following table:


Table 1: DNI letters
||
Remainder 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Letter T R W A G M Y F P D X B N J Z S Q V H L C K E
||

The letters: I, Ñ, O, U are not used. Letter I may be confused with 1, and letter O with 0.

The equivalent to DNI for foreigners is the Number od Identification of Foreigners (NIF), a seven-figure numbers preceded by a X. The same algorithm can be also used to the computation of the letter that correspond to every NIF, rejecting the X and using the seven-figure number.

Your task is to write a program that, for each given number of DNI or NIF, computes the letters that corresponds it.

Input

The input consists of a sequence of DNIs and NIFs. NIF starts with the character X followed by a seven-figure number, while DNI is a eight-figure number.

Output

For each given number, your program must print a line with the letter that corresponds to the DNI or the NIF.

Public test cases
  • Input

    47776371
    12345678
    87654321
    11111111
    22222222
    X1111111
    X2222222
    

    Output

    N
    Z
    X
    H
    J
    G
    P
    
  • Information
    Author
    Miquel Moretó
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++ Python