#C11806. Rotate Matrix by 90 Degrees Clockwise

    ID: 41163 Type: Default 1000ms 256MiB

Rotate Matrix by 90 Degrees Clockwise

Rotate Matrix by 90 Degrees Clockwise

You are given an MxN matrix of integers. Your task is to rotate the matrix by 90° clockwise. The rotation operation transforms the matrix such that the rows become columns in reversed order.

For example, given the following 3x3 matrix:

[ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \ 7 & 8 & 9 \end{bmatrix} ]

The rotated matrix will be:

[ \begin{bmatrix} 7 & 4 & 1 \ 8 & 5 & 2 \ 9 & 6 & 3 \end{bmatrix} ]

Input: The first line of input contains two integers M and N separated by a space. The next M lines each contain N space-separated integers representing the matrix.

Output: Output the rotated matrix as N lines with each line containing M space-separated integers.

Note: All formulas are represented in LaTeX format.

inputFormat

The input consists of:

  • A line with two integers M and N (1 \(\leq M, N \leq 100\)), representing the number of rows and columns of the matrix respectively.
  • Followed by M lines, each containing N space-separated integers, representing the matrix.

outputFormat

Output the rotated matrix. The rotated matrix will have dimensions N x M. Each of the N lines should contain M space-separated integers.

## sample
1 1
5
5

</p>