Secret Code: Largest Number

Time limit3sMemory limit128 MB

Problem

Agent Smith transmits secret information to a secret center: a single strictly positive integer. To encode the number he replaces each digit with the corresponding word and concatenates the words. For example, 42 may become FOURTWO.

Smith knows four languages (numbered 1 to 4). In these languages the digits 0 through 9 are spelled as follows (all letters are capital Latin, ASCII codes 65-90):

DigitLanguage 1Language 2Language 3Language 4
0ZEROSIFIRZEROZERO
1UNUBIRJEDENONE
2DOIIKIDWATWO
3TREIUCTRZYTHREE
4PATRUDORTCZTERYFOUR
5CINCIBESPIECFIVE
6SASEALTISZESCSIX
7SAPTEYEDISIEDEMSEVEN
8OPTSEKIZOSIEMEIGHT
9NOUADOKUZDZIEWIECNINE

After encoding, he adds noise: redundant capital Latin letters. Any letters (including letters already used in the code) may be inserted in any quantity at any positions.

Write a program that reads such a code and finds the largest number it could encode, under two separate assumptions:

  1. The language is unknown, but the same single language, one of the four listed above, was used for the whole number.
  2. Smith may have encoded different digits with different languages, each one of the four listed above, or with the same one.

Input

The input contains several lines; process each line independently. Each line contains at most $10^5$ capital Latin letters -- one code. The total input size is less than 1 MB.

Output

For each input line, output two integers separated by a single space -- the largest numbers under the two assumptions above, in that order.

Each code is guaranteed to come from a correct positive (non-zero) integer, so both answers are always positive. Print them without leading zeroes.