10781 - Two dimensional array rotation (counterclockwise)   

Description

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

Consider the following 2D array:

After being rotated 45 degrees counterclockwise, it will become:

In this case, you should print:

3

2 6

1 5 9

4 8

7

Input

The first line has N (2<=N<=100), 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

10401Mid1



Discuss