Agent Smith transfers to a secret center secret information consisting of one strictly positive integer number. For coding the number, he presents each digit of the number by its corresponding word, and concatenates the words. For example, 42 may be transformed to FOURTWO. Agent Smith knows four languages (the 1st, the 2nd, the 3rd and the 4th). In these languages, numbers from 0 to 9 are spelled as follows (all letters are capital Latin, ASCII codes in range 65–90):
After such encoding, he adds to the code some “noise” — redundant capital Latin chars.
Any chars (including the chars already used in the code) can be added in any quantities in any positions of the code.
Write a program which should read the code and search the largest possible number coded by that code, making two different assumptions:
1. We don’t know what language Smith used, but it was the same language (of the given) overall the code;
2. Smith could code different digits using either different languages (of the given) or the same.