//错了好多次
#include<cstdio>
#include<cstring>
int main(){
<span style="white-space:pre"> </span>int n,count = 0,minLen = 256;
<span style="white-space:pre"> </span>scanf("%d",&n);
<span style="white-space:pre"> </span>char str[n][257];
<span style="white-space:pre"> </span>getchar(); //注意吸收换行
<span style="white-space:pre"> </span>for(int i = 0;i < n;i++){
<span style="white-space:pre"> </span>gets(str[i]); //linux不让用这个了
<span style="white-space:pre"> </span>int len = strlen(str[i]);
<span style="white-space:pre"> </span>if(minLen>len) minLen = len;
<span style="white-space:pre"> </span>for(int j = 0;j < len/2;j++){
<span style="white-space:pre"> </span>char temp = str[i][j];
<span style="white-space:pre"> </span>str[i][j] = str[i][len-j-1];
<span style="white-space:pre"> </span>str[i][len-j-1] = temp;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>for(int i = 0;i < minLen;i++){
<span style="white-space:pre"> </span>bool flag = true;
<span style="white-space:pre"> </span>char std = str[0][i];
<span style="white-space:pre"> </span>for(int j = 1;j < n;j++){
<span style="white-space:pre"> </span>if(str[j][i]!=std){ //分清i,j顺序
<span style="white-space:pre"> </span>flag = false;
<span style="white-space:pre"> </span>break;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>if(!flag) break;
<span style="white-space:pre"> </span>count++;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>if(!count) printf("nai\n");
<span style="white-space:pre"> </span>else{
<span style="white-space:pre"> </span>while(count) printf("%c",str[0][--count]);
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>return 0;
}