eolymp
bolt
Try our new interface for solving problems
Problems

Secret — MAX

Secret — MAX

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, \textbf{42} may be transformed to \textbf{FOURTWO}. Agent Smith knows four languages (the \textbf{1^st}, the \textbf{2^nd}, the \textbf{3^rd} and the \textbf{4^th}). In these languages, numbers from \textbf{0} to \textbf{9} are spelled as follows (all letters are capital Latin, ASCII codes in range \textbf{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: \begin{enumerate} \item We don't know what language Smith used, but it was the same language (of the given)overall the code; \item Smith could code different digits using either different languages (of the given) or the same. \end{enumerate} \InputFile Your program should input all lines and process them separately. Each single line contains not more than \textbf{10^5} capital Latin chars --- the code. Size of the input is less than \textbf{1} Mb. \OutputFile For each line from the input file your program should output two single-space-separated integers --- the largest numbers according to the listed two assumptions in that order. It's guaranteed, that each code was received from a correct positive (non-zero) integer. By the way, it means that both results will be always positive. Your program should output them without leading zeroes.
Time limit 1 second
Memory limit 64 MiB
Input example #1
SIZEROZEROXSIEVDEMX
Output example #1
66 67
Source 2011 South Eastern European Regional Programming Contest, October 15, Problem A