#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int n;
cin>>n;
getchar();
vector<string> ppp;
ppp.resize(n);
getline(cin,ppp[0]);
reverse(ppp[0].begin(),ppp[0].end());
string temp=ppp[0];
for(int i=1;i<n;i++){
string tt;
getline(cin,ppp[i]);
reverse(ppp[i].begin(),ppp[i].end());
string t=ppp[i];
for(int i=0;i<temp.length();i++){
if(temp[i]==t[i]){
tt=tt+temp[i];
}else{
temp=tt;
break;
}
}
}
if(temp.size()==0){
cout<<"nai";
}else{
reverse(temp.begin(),temp.end());
cout<<temp;
}
return 0;
}