10769 - Two-dimensional array rotation   

Description

Given an NxN two-dimensional array M, you are asked to rotate M clockwise by 45 degrees and print out the content of M.

Consider the following 2D array:

After being rotated 45 degrees clockwise, it will become:

In this case, you should print:

1

4 2

7 5 3

8 6

9

 

Input

The first line has N (2<=N<=20), which means the size of the 2D array. The total number of elements in the 2D array is thus N x N.

For the next N lines, each contains N integers, specifying the elements of the 2D array. All of the integers in the same line are separated by a space.

Output

Print out all elements of the rotated 2D array row-by-row.

All of the integers in the same line are separated by a space, and there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss