#K95547. Sorted Matrix Elements
Sorted Matrix Elements
Sorted Matrix Elements
You are given an matrix in which each row and each column is sorted in ascending order. Your task is to output all the elements of the matrix in sorted order.
The input is provided from standard input (stdin) and the output should be printed to standard output (stdout).
For example, given the matrix below:
3
1 5 9
10 11 13
12 13 15
the output should be: 1 5 9 10 11 12 13 13 15
.
inputFormat
The first line of the input contains a single integer , representing the size of the square matrix. The following lines each contain space-separated integers representing the matrix elements.
outputFormat
Print a single line containing all the elements of the matrix in sorted order, separated by spaces.## sample
3
1 5 9
10 11 13
12 13 15
1 5 9 10 11 12 13 13 15