The seating chart was written row-wise, but the principal wants it column-wise. That means flipping the matrix over its diagonal: row i becomes column i.
Print the transpose of the given matrix.
Input Format The first line has r and c. Each of the next r lines has c integers.
Output Format Print c lines, each with r integers separated by spaces: the transposed matrix.
Constraints • 1 ≤ r, c ≤ 100 • -1000 ≤ value ≤ 1000
Examples
Example 1
Input
2 3
1 2 3
4 5 6
Output
1 4
2 5
3 6
Explanation Columns (1,4), (2,5), (3,6) become rows.
Example 2
Input
1 3
7 8 9
Output
7
8
9
Explanation A single row becomes a single column.
Example 3
Input
2 2
1 2
3 4
Output
1 3
2 4
Explanation 1 and 4 stay, while 2 and 3 swap places.
Acceptance—
Accepted0
Submissions0
Auto-save
SavedLn 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
1 4
2 5
3 6
No results yet
Run your code to test it against the sample cases.