import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scn =new Scanner(System.in);
int rows=scn.nextInt();
int[][] array=new int[rows][rows];
for(int i=0;i<array.length;i++) {
for(int j=0;j<array[i].length;j++) {
array[i][j]=scn.nextInt();
}
}spiralprint(array);
}
private static void spiralprint(int[][] arr) {
int top = 0;
int bottom = arr.length - 1;
int right = arr[top].length - 1;
int left = 0;
int dir = 1;
int count = (bottom + 1) * (right + 1);
while (right >= 0) {
if (count > 0) {
if (dir == 1) {
for (int i = top; i <= bottom; i++) {
System.out.print(arr[i][right] + " ");
count--;
}
System.out.println();
right -= 1;
}
}
}
}
}