beecrowd | 2714

My Temporary Password

By , Silva A. M. BR Brazil

Timelimit: 1

An educational institution has as a practice to assign access password to the academic portal to use the RA (academic record) of the student. In this institution RA's are 20-character strings always initialized by the characters "RA" and followed by 18 numeric digits. for example: RA000000000000012340. These identifiers are automatically generated by the registration system and are formed by three main parts: (a) initialized by the characters "RA", (b) followed by Z zeros which are position formatters (where, 0 <= Z <= 17 ), and finally, (c) the student's own identification number, considering the X numbers to the right of the RA not initiated by zero (where, 1 <= X <= 18).

Input

The first entry line is an integer value N (1 <= N <= 1000) that represents the amount of RA's that the program must account for. The following N lines each represent strings of up to 100 characters representing the RAs sent by the registration system.

Output

The valid outputs for the program are: the presentation of the provisional password or the indication of "INVALID DATA". The temporary password is made up of the X numeric characters not started at 0 to the right of the string, for example: for the identifier "RA000000000000012340" the temporary password must be "12340". If the received string does not conform to the training rules, the program should indicate "INVALID DATA".

Input Samples Output Samples

7
RA000000000000000001
RA000000000000000100
RA000000000000012345
RA123456789012345678
ra000000000000000333
RA12345
12345678901234567890
 

1
100
12345
123456789012345678
INVALID DATA
INVALID DATA
INVALID DATA