//不需要真的交换,只需要存下来行的坐标,按序输出每一行即可
//按列遍历数组,直接找出每列中除去依照的的行后的最大的元素的行
//bool b[] 标记要去除的行号
//vector<>v 存下来依次需要交换的行
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#define maxn 15
using namespace std;
int a[maxn][maxn];
bool b[maxn];
int main() {
int n;
while (cin >> n) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
}
}
vector<int>v;
for (int i = 1; i <= n; i++) {//列
int maxx = -9999, pos;
for (int j = 1; j <= n; j++) {
if (a[j][i] > maxx && b[j] == 0) {
maxx = a[j][i];
pos = j;
}
}
b[pos] = 1;
v.push_back(pos);
}
for(int i=0;i<v.size();i++)
{
for(int j =1;j<=n;j++)
{
cout<<a[v[i]][j]<<" ";
}
cout<<endl;
}
}
}
// 64 位输出请用 printf("%lld")