Олимпиадный тренинг

Задача 45719. Sorting a two-dimensional array


Write a program that sorts a two-dimensional array of integers. In this case, the smallest number should be in the first element of the first line, and the largest in the last element of the last line.


Input

The first line contains space-separated dimensions of a two-dimensional array: the number of rows N and the number of columns M ( 1 <=  N , M <= 100 ). The following N lines contain the strings of a two-dimensional array, each – by M natural numbers separated by spaces. 
 

Output

The program should output a sorted two-dimensional array.
 

Examples
# Input Output
1
5 6
13 5 1 8 4 14 5 
5 13 10 9 3 7 7 
3 3 9 6 3 7 5 
10 8 11 2 1 1 13 
1 12 13 15 9 11 4 
1 1 1 1 2 3 3 
3 3 4 4 5 5 5 
5 6 7 7 7 8 8 
9 9 9 10 10 11 11 
12 13 13 13 13 14 15

Запрещенные операторы:sort