从后往前配对
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main() {
int n;
string ans="";
cin >> n;
string tmp;
cin.get();
getline(cin, ans);
n--;
bool flag = true;
while(n--) {
getline(cin, tmp);
int i = tmp.length()-1;
int j = ans.length()-1;
if(ans[j] != tmp[i]) {
flag = false;
continue;
}
while(i>=0) {
if(ans[j] == tmp[i]) {
j--;
i--;
} else break;
}
ans = ans.substr(j+1);
}
if(!flag) cout << "nai" << endl;
else cout << ans << endl;
return 0;
}