#include<bits/stdc++.h>
using namespace std;
int main(){
cin.sync_with_stdio(false);
int n;
set< pair < int,int > > next;
set< pair < int,int > > now;
char c='Z'+1;
int m=1;
cin>>n;
string s[n];
for(int i=0;i<n;i++){
cin>>s[i];
}
now.emplace(pair< int,int> (0,0));
int x,y;
while(m<n*2){
for(set< pair< int, int> i=now.begin();i!=now.end();i++){
x=(*i).first;
y=(*i).second;
if(s[y][x]<c){
next.clear();
c=s[y][x];
}
if(s[y][x]==c){
if(x!=n-1){
next.emplace(pair< int,int> (x+1,y));
}
if(y!=n-1){
next.emplace(pair< int,int> (x,y+1));
}
}
}
cout<<c;
c='Z'+1;
m++;
now=next;
set < pair< int,int> > next;
}
cout<<"\n";
return 0;
}