package asdf;
public class Q3 {
static IO io = new IO();
static int n;
static char[][] table;
static String ans = "";
public static void main(String[] fuckingCopyRightBreaker){
n = io.nextInt();
table = new char[n][n];
for(int i = 0; i < n; i++){
table[i] = io.next().toCharArray();
}
io.print(goTo(0, 0, ""));
io.close();
}
private static String goTo(int x, int y, String s){
s += table[x][y];
if(x == n - 1 && y == n - 1){
return s;
}else if(x == n - 1){
return goTo(x, y + 1, s);
}else if(y == n - 1){
return goTo(x + 1, y, s);
}else{
if((int)table[x + 1][y] == (int)table[x][y + 1]){
String s1 = goTo(x + 1, y, s);
String s2 = goTo(x, y + 1, s);
if(s1.compareTo(s2) <= 0){
return s1;
}else{
return s2;
}
}else if((int)table[x + 1][y] < (int)table[x][y + 1]){
return goTo(x + 1, y, s);
}else{
return goTo(x, y + 1, s);
}
}
}
}