#C11403. Matrix Rotation by 90° Clockwise

    ID: 40716 Type: Default 1000ms 256MiB

Matrix Rotation by 90° Clockwise

Matrix Rotation by 90° Clockwise

Given an N × M matrix, your task is to rotate the matrix by $90^\circ$ clockwise. The rotated matrix will have dimensions M × N. This is a classic problem in programming contests that tests your ability to manipulate two-dimensional arrays.

Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line contains two space-separated integers N and M, representing the number of rows and columns of the matrix respectively.

Then follow N lines, each containing M space-separated integers representing the elements of the matrix.

outputFormat

Output the rotated matrix in M lines. Each line should contain the elements of the row 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>