Problem D
Scramble Sort

Background

In this problem you will be given a series of lists containing of pairs of words and numbers. The goal is to sort these lists in two ways. The first objective is to create a list of the words sorted according the the numerical order of their corresponding numbers. The second objective is to create a list of the numbers sorted according to th alphabetical order of their corresponding words (ignoring case).

Ties should be broken with the other element of the pair. That is, if there are two identical values (which are used to sort their corresponding words), the tie is broken by the relative alphabetic order of the words (again, case-insensitive). Also, note that the output words and numbers should be exactly the words and numeric strings read in. The numbers will all be valid doubles.

Input

The input will contain lists of (word,number) pairs, one list per line. Each element of the list will be separated by a comma followed a space, and the list will be terminated by a period. Within each pair there will appear neither spaces nor other non-letter characters. The input will be terminated by a line containing only a single period.

Output

For each list in the input, output two lists, one per line: first, the list of the words sorted according to their corresponding numbers and then the list of numbers sorted according to their Separate each element of these lists with a comma followed by a space, and end the list with a period (and a newline).

Example

Input

(one,1), (two,2.0), (three,3), (acm,-70).
(banana,3.14), (strawberry,2.71), (OrAnGe,1.41).
.

Output

acm, one, two, three.
-70, 1, 3, 2.0.
OrAnGe, strawberry, banana.
3.14, 1.41, 2.71.