11257 - Segment Sorting   

Description

Given m (m<=5) segments, each of which contains n (n<=10) integers.

You are asked to sort each segment individually in increasing order.

For example:

Given m = 3, n = 4 and the segments

[ 1 9 3 4 ] [ 7 11 6 2 ] [ 12 8 5 10 ]

the result after the sorting should be:

[ 1 3 4 9 ] [ 2 6 7 11 ] [ 5 8 10 12 ]

and therefore you should print:

1 3 4 9 2 6 7 11 5 8 10 12

Input

The first line contains two integers m (m<=5) and n (n<=10),

where m means the number of segments

and n means the size of each segment.

The second line contains n*m integers seperated by a space.

Output

You need to print the final sequence.
There should be one space between two adjacent integers.

Note that you DO NOT need to print a space(' ') or a newline (‘\n’) at the end of the line.

Sample Input  Download

Sample Output  Download

Tags




Discuss