import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Zscan {
static Scanner sc;
static int n; // 表示矩阵的行数和列数
static int[][] point;
static String direction = "right";// 表示方向
static int row;
static int col;
static List<Integer> list;
static int count;
public static void main(String[] args) {
sc = new Scanner(System.in);
n = sc.nextInt();
point = new int[n][n];
list = new ArrayList<>();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
point[i][j] = sc.nextInt();
}
}
while (count <= n * n) {
count++;
if (row <= n - 1 && col <= n - 1) {
list.add(point[row][col]);
}
if (direction.equals("right")) {
// 那么行不变 列加1
col++;
if (row == 0 && col < n) {
// 表示如果是在第一行 那么接下来应该是往左下角走
direction = "leftdown";
} else if (row == n - 1 && col < n) {
// 如果是在最底下 应该是往右上角走
direction = "rightup";
}
} else if (direction.equals("leftdown")) {
row++;
col--;
if (col > 0 && row < n - 1) {
// 如果一直在这个范围之内 那么就一直往左下角走
direction = "leftdown";
} else if (col == 0 && row < n - 1) {
// 如果已经到了最左边 那么向下走
direction = "down";
} else if (col >= 0 && row == n - 1) {
// 如果到了最下面 那么向右边走
direction = "right";
}
} else if (direction.equals("down")) {
row++;
if (col == 0) {
// 如果已经是在最左左边 那么网右上边走
direction = "rightup";
} else if (col == n - 1) {
// 如果已经是在最右边 那么往左下边走
direction = "leftdown";
}
} else if (direction.equals("rightup")) {
row--;
col++;
if (row > 0 && col < n - 1) { // 如果一直是在这个范围之内 那么一直往右上角走
direction = "rightup";
} else if (row == 0 && col < n - 1) {
// 如果已经到了最上面 那么就往右边走
direction = "right";
} else if (row >= 0 && col == n - 1) {
// 如果已经到了最右边 那么就往下面走
direction = "down";
}
}
}
for (int i = 0; i < list.size(); i++) {
System.out.print(list.get(i) + " ");
}
}
}