Problems > Transpose

Transpose

Difficulty: 900 2000 ms 128 MB

implementation

Print the transpose of the N×M matrix (an M×N matrix).

Input: the first line has N and M; the next N lines each have M integers.

Output: M lines of N integers.

Constraints:

  • 1 ≤ N, M ≤ 100

Sample Tests

Input 1
2 3
1 2 3
4 5 6
Output 1
1 4
2 5
3 6
Input 2
1 1
7
Output 2
7

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.