#C8796. Rotate Matrix 90 Degrees Clockwise

    ID: 52817 Type: Default 1000ms 256MiB

Rotate Matrix 90 Degrees Clockwise

Rotate Matrix 90 Degrees Clockwise

Given an \(N \times M\) matrix, rotate it by 90 degrees clockwise. The rotated matrix will have dimensions \(M \times N\). Specifically, if the element in the original matrix is denoted by \(a_{ij}\) where \(i\) is the row index and \(j\) is the column index (0-indexed), then the rotated matrix is defined such that its element at position \(b_{jk}\) is given by \(b_{jk} = a_{(N-1-k)j}\). Solve the problem by reading the matrix from standard input and outputting the rotated matrix to standard output.

Example:

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

Output: 7 4 1 8 5 2 9 6 3

</p>

inputFormat

The first line contains two space-separated integers \(N\) and \(M\), representing the number of rows and columns of the matrix respectively. The following \(N\) lines each contain \(M\) space-separated integers representing the matrix rows.

outputFormat

Output the rotated matrix. Each row of the matrix should be printed in a separate line with the elements separated by a single space.

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

8 5 2 9 6 3

</p>