#P6547. Extract and Sort Numbers

    ID: 19760 Type: Default 1000ms 256MiB

Extract and Sort Numbers

Extract and Sort Numbers

Little Mirko got a boring math assignment. His teacher provided him with a text consisting of n lines that contain only digits and lowercase letters. Mirko must extract all the maximal contiguous digit sequences from the text, remove any leading zeros from these sequences, and then output the numbers in non-decreasing (ascending) order. A number is defined as the largest possible sequence of consecutive digits that is delimited either by letters or by the beginning/end of a line.

For example, given the input line:

01a2b3456cde478

the extracted and processed numbers are 1, 2, 3456, 478, and after sorting in non-decreasing order, the final output is:

1 2 478 3456

inputFormat

The input starts with an integer n denoting the number of lines. The following n lines each contain a string composed of digits and lowercase letters.

outputFormat

Output all the extracted numbers in non-decreasing order, separated by a single space. Each number must be displayed without leading zeros.

sample

1
01a2b3456cde478
1 2 478 3456