#include <iostream>
#include <fstream>
using namespace std;
int a[101][101];
ifstream f("matrice.in");
ofstream g("matrice.out");
int cautapozmin(int n)
{
int min=1001, p=0;
for (int i=1; i<=n; ++i)
if (a[i][i]<min) { min=a[i][i]; p=i; }
return p;
}
void modifica(int poz, int &n)
{
int i,j;
for (i=poz; i<n; ++i)
for (j=1; j<=n; ++j)
a[i][j]=a[i+1][j];
for (j=poz; j<n; ++j)
for (i=1; i<=n; ++i)
a[i][j]=a[i][j+1];
--n;
}
void afisare(int n)
{
int i, j;
for (i=1; i<=n; ++i)
{
for (j=1; j<=n; ++j)
g << a[i][j] << " ";
g << "\n";
}
}
int main()
{
int n, i, j, poz;
f >> n;
for (i=1; i<=n; ++i)
for (j=1; j<=n; ++j)
f >> a[i][j];
poz=cautapozmin(n);
modifica(poz,n);
poz=cautapozmin(n);
modifica(poz,n);
afisare(n);
return 0;
}