#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n, matrice[255][255];
cin>>n;
for(int i=1; iM=n; i++){
for(int j=1; j<=n; j++){
cin>>matrice[i][j];
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
if( i == 1 ){
if( matrice[i][j] < matrice[i][j-1] && matrice[i][j] < matrice[i][j+1] && matrice[i][j] < matrice[i-1][j] ){
cout<<matrice[i][j]<<" ";
}
}else if( matrice[i][j] < matrice[i+1][j] && matrice[i][j] < matrice[i-1][j] && matrice[i][j] < matrice[i][j+1] && matrice[i][j-1] ){
cout<<matrice[i][j]<<" ";
}
}
}
}