#K60062. Matrix Rotation by 90° Clockwise

    ID: 31003 Type: Default 1000ms 256MiB

Matrix Rotation by 90° Clockwise

Matrix Rotation by 90° Clockwise

You are given a matrix with dimensions \(n \times m\). Your task is to rotate this matrix by 90° clockwise.

The first line of input contains two integers \(n\) and \(m\) --- the number of rows and columns respectively. The following \(n\) lines each contain \(m\) integers representing the matrix elements.

Your program should output the rotated matrix, where each row of the resulting matrix is printed on a new line with elements separated by a space.

inputFormat

The input is read from stdin and has the following format:

n m
row1
row2
... 
rown

Here, the first line contains two integers \(n\) and \(m\), and then there are \(n\) lines each containing \(m\) space-separated integers.

outputFormat

The output should be written to stdout and consist of the rotated matrix. Each line of output represents one row of the rotated matrix, with elements separated by a space.

## sample
3 4
1 2 3 4
5 6 7 8
9 10 11 12
9 5 1

10 6 2 11 7 3 12 8 4

</p>