#include <iostream>
using namespace std;
int main() {
int n, m[101][101];
cin >> n;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
cin >> m[i][j];
}
}
// parcurgem fiecare element de pe prima linie
for (int j = n; j >= 1; --j) {
int linie = 1, coloana = j;
// parcurgem paralela la diagonală
while (linie <= n && coloana <= n) {
cout << m[linie][coloana] << ' ';
++linie;
++coloana;
}
cout << '\n';
}
// parcurgem fiecare element de pe prima coloană
for (int i = 2; i <= n; ++i) {
int linie = i, coloana = 1;
// parcurgem paralela la diagonală
while (linie <= n && coloana <= n) {
cout << m[linie][coloana] << ' ';
++linie;
++coloana;
}
cout << '\n';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgaW50IG4sIG1bMTAxXVsxMDFdOwogIGNpbiA+PiBuOwogIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgZm9yIChpbnQgaiA9IDE7IGogPD0gbjsgKytqKSB7CiAgICAgIGNpbiA+PiBtW2ldW2pdOwogICAgfQogIH0KICAvLyBwYXJjdXJnZW0gZmllY2FyZSBlbGVtZW50IGRlIHBlIHByaW1hIGxpbmllCiAgZm9yIChpbnQgaiA9IG47IGogPj0gMTsgLS1qKSB7CiAgICBpbnQgbGluaWUgPSAxLCBjb2xvYW5hID0gajsKICAgIC8vIHBhcmN1cmdlbSBwYXJhbGVsYSBsYSBkaWFnb25hbMSDCiAgICB3aGlsZSAobGluaWUgPD0gbiAmJiBjb2xvYW5hIDw9IG4pIHsKICAgICAgY291dCA8PCBtW2xpbmllXVtjb2xvYW5hXSA8PCAnICc7CiAgICAgICsrbGluaWU7CiAgICAgICsrY29sb2FuYTsKICAgIH0KICAgIGNvdXQgPDwgJ1xuJzsKICB9CiAgLy8gcGFyY3VyZ2VtIGZpZWNhcmUgZWxlbWVudCBkZSBwZSBwcmltYSBjb2xvYW7EgwogIGZvciAoaW50IGkgPSAyOyBpIDw9IG47ICsraSkgewogICAgaW50IGxpbmllID0gaSwgY29sb2FuYSA9IDE7CiAgICAvLyBwYXJjdXJnZW0gcGFyYWxlbGEgbGEgZGlhZ29uYWzEgwogICAgd2hpbGUgKGxpbmllIDw9IG4gJiYgY29sb2FuYSA8PSBuKSB7CiAgICAgIGNvdXQgPDwgbVtsaW5pZV1bY29sb2FuYV0gPDwgJyAnOwogICAgICArK2xpbmllOwogICAgICArK2NvbG9hbmE7CiAgICB9CiAgICBjb3V0IDw8ICdcbic7CiAgfQogIHJldHVybiAwOwp9