#K82027. Rotate Matrix 90° Clockwise

    ID: 35884 Type: Default 1000ms 256MiB

Rotate Matrix 90° Clockwise

Rotate Matrix 90° Clockwise

Given an ( M \times N ) matrix of integers, rotate the matrix by 90° clockwise. The rotation transforms the element at position ( (i, j) ) in the original matrix to position ( (j, M-1-i) ) in the rotated matrix.

For example, if the input matrix is:
(\begin{pmatrix}1 & 2 & 3\4 & 5 & 6\7 & 8 & 9\end{pmatrix})
then the rotated matrix will be:
(\begin{pmatrix}7 & 4 & 1\8 & 5 & 2\9 & 6 & 3\end{pmatrix})

inputFormat

The first line contains two integers ( M ) and ( N ), representing the number of rows and columns of the matrix, respectively. Each of the following ( M ) lines contains ( N ) space-separated integers denoting a row of the matrix.

outputFormat

Output the rotated matrix. Each line of the output corresponds to one row of the rotated matrix, with each element separated by a space.## sample

3 3
1 2 3
4 5 6
7 8 9
7 4 1

8 5 2 9 6 3

</p>