#include <iostream>
using namespace std;

const int MAX_LENGTH = 50;

int main() {
    int noElem, mt[MAX_LENGTH][MAX_LENGTH];
    cin >> noElem;

    // Citirea matricei
    for (int i = 0; i < noElem; ++i) {
        for (int j = 0; j < noElem; ++j) {
            cin >> mt[i][j];
        }
    }

    // Traversarea meandrată a matricei
    for (int diag = 0; diag < 2 * noElem - 1; ++diag) {
        int start_row = diag < noElem ? diag : noElem - 1;
        int start_col = diag < noElem ? 0 : diag - noElem + 1;

        if (diag % 2 == 0) {
            // Diagonale în sus (stânga la dreapta)
            for (int r = start_row, c = start_col; r >= 0 && c < noElem; --r, ++c) {
                cout << mt[r][c] << " ";
            }
        } else {
            // Diagonale în jos (dreapta la stânga)
            for (int r = start_col, c = start_row; r < noElem && c >= 0; ++r, --c) {
                cout << mt[r][c] << " ";
            }
        }
    }

    return 0;
}
