eolymp
bolt
Try our new interface for solving problems
Problems

The Diputs notation

The Diputs notation

Time limit 0.5 seconds
Memory limit 256 MiB

The Diputs notation is a notation to represent non-negative integer numbers. Diputs notation has 9 digits, starting with the least significant:

_.,- ='^

There can be a limited quantity of each digit character in the number representation:

A number representation in Diputs notation starts with the most significant digit, e.g.:

"""^^  -,..__

Let us write down all possible number representations in Diputs notation and arrange them in the following order. Number A goes after number B if the representation of A in Diputs notation has more '"' (most significant digit) characters than the representation of B. If the numbers A and B have equal number of '"' characters, we then compare the number of '^' characters, and so on. Then we number this sequence, starting from 1 - and the result is the map which defines how numbers are represented in Diputs notation. Zero is represented with the 'O' character (code 79).

Examples:

Input data

There is an input containing numbers in decimal notation, numbers in Diputs notation, and some other text.

Output data

You must output the same numbers, but in another notation: the numbers in decimal notation should be converted to Diputs notation, and the numbers in Diputs notation should be converted to decimals. All numbers in the input are non-negative and do not exceed maximum number representable in Diputs notation. It is possible that the numbers will not be separated by space or other characters. You should parse the numbers in greedy way: when reading a number, you should take maximum number of characters that can form a decimal or Diputs representation of a number. For example, if you have three underscore characters ("___"), you should parse it as numbers "__" (2) and "_" (1) in Diputs notation. In this case, the resulting string will be "21". When parsing decimal numbers, your program should work the same way. There should be no leading zeros in decimal numbers. For example, you should parse the string "020" as decimal numbers 0 and 20, and the result will be "O,..__". If you would get a decimal number larger than the maximum number representable in Diputs notation, you should split it into two or more decimal numbers in greedy way, as described.

Some examples:

Because we feel that your task is too easy, you should sort the numbers in ascending order, if the total number of numbers in the input is odd. Only numbers should be reordered; the notation of a number in a certain location should not be changed. For example, for input "2 O _" you should first recognize the notation (decimal, diputs, diputs), then convert it to "__ 0 1", inverting the notation (it is now diputs, decimal, decimal), and then sort the numbers while preserving the notation. Thus, the sorted array is 0, 1 and 2, the notations are (diputs, decimal, decimal), so the answer should be "O 1 2". Take a look at the sample input for better understanding.

Size of input and output will not exceed 1 megabyte (10^6 bytes).

Examples

Input example #1
need 2 sort
O
_
Output example #1
need O sort
1
2
Source Izhevsk STU Contest, Petrozavodsk training camp, February 6, 2009