#C6049. Rotate Square Matrix 90° Clockwise

    ID: 49766 Type: Default 1000ms 256MiB

Rotate Square Matrix 90° Clockwise

Rotate Square Matrix 90° Clockwise

You are given a square matrix of size (N \times N). Your task is to rotate the matrix by 90° clockwise. In mathematical terms, every element at position ( (i,j) ) in the original matrix moves to position ( (j, N-1-i) ) in the rotated matrix. This transformation will be applied to several test cases. Make sure your solution reads from standard input and writes the rotated matrix to standard output.

inputFormat

The input begins with an integer (T) representing the number of test cases. For each test case, the first line contains an integer (N) (the dimension of the matrix), followed by (N) lines each containing (N) space-separated integers representing the rows of the matrix.

outputFormat

For each test case, output the rotated matrix. Each row of the rotated matrix should be printed on a separate line with the elements separated by a single space. The outputs for different test cases should follow consecutively.## sample

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

8 5 2 9 6 3 3 1 4 2 5

</p>