~/algor $ cat problems/matritsa-90-gradusga-burish
Rotate by 90 degrees
Medium
1000 ms
128 MB
48%
An integer matrix of size $n \times m$ is given. Rotate it $90^{\circ}$ clockwise and print the resulting $m \times n$ matrix: the first row of the original becomes the last column of the result.
Input
The first line contains two positive integers $n$ and $m$. Each of the next $n$ lines contains $m$ integers.
Output
$m$ lines with $n$ space-separated integers each.
Note
$1 \le n, m \le 200$
$-1000 \le a_{i,j} \le 1000$
Examples
Input #1
2 3 1 2 3 4 5 6
Output #1
4 1 5 2 6 3
Input #2
1 3 7 8 9
Output #2
7 8 9