#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;
int lineSum[MAX_SIZE + 1];
for (int line = 1; line <= size; ++line) {
lineSum[line] = 0;
for (int col = 1; col <= size; ++col) {
cin >> mt[line][col];
lineSum[line] += mt[line][col];
}
++sumFreq[lineSum[line]];
}
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 == lineSum[line] /*&& line != nextLinePos*/) {
if (line != nextLinePos) {
int aux1 = lineSum[nextLinePos];
lineSum[nextLinePos] = lineSum[line];
lineSum[line] = aux1;
for (int col = 1; col <= size; ++col) {
int aux2 = mt[nextLinePos][col];
mt[nextLinePos][col] = mt[line][col];
mt[line][col] = aux2;
}
}
for (int col = 1; col <= size; ++col) {
cout << mt[nextLinePos][col] << " ";
}
line = size + 1;
cout << "\n";
}
}
}
}
return 0;
}