#include <iostream>
using namespace std;
const int MAX_SIZE = 5;
const int MAX_VALUE = 10;
int sumFreq[MAX_SIZE * MAX_VALUE + 1];
int main() {
int size, mt[MAX_SIZE + 1][MAX_SIZE + 1];
cin >> size;
for (int line = 1; line <= size; ++line) {
mt[line][0] = 0;
for (int col = 1; col <= size; ++col) {
cin >> mt[line][col];
mt[line][0] += mt[line][col];
}
++sumFreq[mt[line][0]];
}
int nextLinePos = 0;
for (int i = 0; i <= size * MAX_VALUE; ++i) {
if (sumFreq[i] == 1) {
++nextLinePos;
for (int line = nextLinePos; line <= size; ++line) {
if (i == mt[line][0]) {
if (line != nextLinePos) {
for (int col = 0; col <= size; ++col) {
int aux = mt[nextLinePos][col];
mt[nextLinePos][col] = mt[line][col];
mt[line][col] = aux;
}
}
for (int col = 1; col <= size; ++col) {
cout << mt[nextLinePos][col] << " ";
}
line = size + 1;
cout << "\n";
}
}
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gNTsKY29uc3QgaW50IE1BWF9WQUxVRSA9IDEwOwppbnQgc3VtRnJlcVtNQVhfU0laRSAqIE1BWF9WQUxVRSArIDFdOwoKaW50IG1haW4oKSB7CiAgICBpbnQgc2l6ZSwgbXRbTUFYX1NJWkUgKyAxXVtNQVhfU0laRSArIDFdOwogICAgY2luID4+IHNpemU7CiAgICBmb3IgKGludCBsaW5lID0gMTsgbGluZSA8PSBzaXplOyArK2xpbmUpIHsKICAgICAgICBtdFtsaW5lXVswXSA9IDA7CiAgICAgICAgZm9yIChpbnQgY29sID0gMTsgY29sIDw9IHNpemU7ICsrY29sKSB7CiAgICAgICAgICAgIGNpbiA+PiBtdFtsaW5lXVtjb2xdOwogICAgICAgICAgICBtdFtsaW5lXVswXSArPSBtdFtsaW5lXVtjb2xdOwogICAgICAgIH0KICAgICAgICArK3N1bUZyZXFbbXRbbGluZV1bMF1dOwogICAgfQogICAgaW50IG5leHRMaW5lUG9zID0gMDsKICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IHNpemUgKiBNQVhfVkFMVUU7ICsraSkgewogICAgICAgIGlmIChzdW1GcmVxW2ldID09IDEpIHsKICAgICAgICAgICAgKytuZXh0TGluZVBvczsKICAgICAgICAgICAgZm9yIChpbnQgbGluZSA9IG5leHRMaW5lUG9zOyBsaW5lIDw9IHNpemU7ICsrbGluZSkgewogICAgICAgICAgICAgICAgaWYgKGkgPT0gbXRbbGluZV1bMF0pIHsKICAgICAgICAgICAgICAgICAgICBpZiAobGluZSAhPSBuZXh0TGluZVBvcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBjb2wgPSAwOyBjb2wgPD0gc2l6ZTsgKytjb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBhdXggPSBtdFtuZXh0TGluZVBvc11bY29sXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10W25leHRMaW5lUG9zXVtjb2xdID0gbXRbbGluZV1bY29sXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10W2xpbmVdW2NvbF0gPSBhdXg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgY29sID0gMTsgY29sIDw9IHNpemU7ICsrY29sKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgbXRbbmV4dExpbmVQb3NdW2NvbF0gPDwgIiAiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsaW5lID0gc2l6ZSArIDE7CiAgICAgICAgICAgICAgICAgICAgY291dCA8PCAiXG4iOwogICAgICAgICAgICAgICAgfSAKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9