#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[120][260];
int len[120];
int main()
{
int n;
char s1[260];
scanf("%d",&n);
getchar();
for(int i = 0; i < n; i++)
{
fgets(s[i],260,stdin);
}
int minlen = 1000000,u = -1;
for(int i = 0 ;i < n; i++)
{
len[i] = strlen(s[i])-1;
if(len[i] < minlen)
{
minlen = len[i];
u = i;minlen = min(len[i],minlen);
}
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < len[i]/2; j++)
{
char temp = s[i][j];
s[i][j] = s[i][len[i]-1-j];
s[i][len[i]-1-j] = temp;
}
}
int ans = 0;
for(int i = 0; i < minlen ; i++)
{
int flag = 1;
char c = s[0][i];
for(int j = 1; j < n; j++)
{
if(s[j][i] != c)
{
flag = 0;
break;
}
}
if(flag == 1)
{
ans++;
}
else break;
}
if(ans == 0) printf("nai\n");
else
{
for(int i = ans-1; i >= 0; i--)
printf("%c",s[0][i]);
}
return 0;
}