#K65552. Rotate Matrix 90 Degrees Clockwise

    ID: 32222 Type: Default 1000ms 256MiB

Rotate Matrix 90 Degrees Clockwise

Rotate Matrix 90 Degrees Clockwise

You are given an \(N \times N\) matrix. Your task is to rotate the matrix by 90° clockwise.

The first line of the input contains a single integer \(N\) denoting the size of the matrix. Each of the next \(N\) lines contains \(N\) integers separated by spaces, representing the rows of the matrix.

You need to output the rotated matrix in the same format: each row's elements separated by a single space.

inputFormat

Input is read from stdin and has the following format:

N
row1
row2
...
rowN

Where:

  • \(N\) is an integer that represents the number of rows and columns in the matrix.
  • Each row contains \(N\) space-separated integers.

outputFormat

Output the rotated matrix to stdout in the following format:

rotated_row1
rotated_row2
...
rotated_rowN

Each row of the rotated matrix should have the 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>