import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[][] num = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
num[i][j] = scanner.nextInt();
}
}
// 定义一个标志,true向右,false向左,开始默认向右
boolean flag = true;
int right = 0;
int left = 0;
int N = (n - 1) * 2;
while (true) {
System.out.print(num[left][right] + " ");
// 当遍历到最后一个元素时退出循环
if (right + left == N)
break;
if (flag) { // 向右
int tmp = right;
while (left > tmp) { // 当left为right原先值时
left--;
right++;
System.out.print(num[left][right] + " ");
}
} else { // 向左
int tmp = left;
while (right > tmp) {// 当right为left原先值时
right--;
left++;
System.out.print(num[left][right] + " ");
}
}
if (flag) { // 向右时看是否到了尽头
if (right + 1 < n)
right++;
else
left++;
flag = false;
} else { // 向左时看是否到了尽头
if (left + 1 < n)
left++;
else
right++;
flag = true;
}
}
scanner.close();
}
}