Little Spiderman is in the 10th grade. He learns about matrixes and their transpose. His homework is to find the transpose matrix of a given matrix, but he doesn't know how to do this, since he hasn't been bitten by the radioactive spider yet. Let's help him do the homework.
Input
The first line of input contains two integers N and M.
The following N lines contain M space-separated values each, representing the original matrix.
Output
The output should contain M lines of N space-separated values, representing the transpose matrix.
Constraints
- 1 ≤ N, M ≤ 1000
- 1 ≤ any matrix value ≤ 32768
Sample
Input | Output |
---|---|
2 3 4 8 15 16 23 423 | 4 16 8 23 15 423 |
Python 2.7
1 n, m = map(int, raw_input().split()) 2 a = [list(raw_input().split()) for i in range(n)] 3 4 print '\n'.join([' '.join([a[i][j] for i in range(n)]) for j in range(m)])