#C5045. Matrix Rotation (90° Clockwise)

    ID: 48651 Type: Default 1000ms 256MiB

Matrix Rotation (90° Clockwise)

Matrix Rotation (90° Clockwise)

The task is to rotate a given square matrix by 90° clockwise. You are provided with an integer \(n\) denoting the size of the matrix, followed by \(n\) lines each containing \(n\) space-separated integers. In the rotated matrix, each element \(a_{i,j}\) from the original matrix will move to position \(a_{j, n-i-1}\), i.e., the first row becomes the last column, the second row becomes the second-to-last column, and so on.

Example:

Input:
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 an integer n, which represents the number of rows and columns of the square matrix. Each of the following n lines contains n space-separated integers representing the matrix rows.

outputFormat

Output the rotated matrix. Each row should be printed on a new line with the matrix elements separated by a single space.## sample

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

8 5 2 9 6 3

</p>