#ACSL1617S2. ACSL1617S2

ACSL1617S2

PROBLEM: This program requires you to take a string of digits and form a sequence ofnumbers from that string, such that each number is larger than the previous number in thesequence. To form the numbers in the sequence, you take digits from the left side of the initialstring, then from the right, then from the left, then from the right, and so on, until the remainingdigits of the string cannot be formed into a number larger than the previous number in the sequence.

For example, the string 31415926538 would form the sequence of numbers 3, 8, 14, 35, and 159: image

The first number in the sequence is the leftmost digit inthe input string, the number 3. The next digit to consider is from the right side, the 8. This is larger than the 3, so it's in the sequence. Next, we go back to and look at the left side. Thenumber lis not greater than 8, so we go further andcombine it with the 4 to make the number 14, which islarger than 8, it's part of the sequence. Back to the right side, where we consider the number 3then 5. The number 35 is larger than 14, so it’s part ofthe sequence. Back to the left side and select 159 Back to the right side and ignore the 62 since it issmaller than 159

INPUT: There will be 5 lines of input. Each line will contain a string of digits. Its length will beat least 1 and no more than 32.

OUTPUT: The sequence of numbers formed as described above; each number in the sequencemust be separated by a single space. Any number in the output sequence that starts with a zeromust not show the leading zero.

SAMPLE INPUT

31415926538
314159265
201617
123456789
1223334444

SAMPLE OUTPUT

3 8 14 35 159
3 5 14 62 159
2 7 16
1 9 23 87 456
1 4 22 44 333