#include <stdio.h>
#include <string.h>
int ex_next[305], maxlen, pos;
int ans[305], best;
inline int max(int a, int b) {
return a > b ? a : b;
}
void get_ex_next(char ch[]) {
memset(ex_next,0,sizeof(ex_next));
int m = strlen(ch);
int j = 0, k = 1;
ex_next[0] = m;
while(ch[j] == ch[j + 1]) j ++;
ex_next[1] = j;
for(int i = 2; i < m; i ++) {
int len = k + ex_next[k], L = ex_next[i - k];
if( L < len - i) {
ex_next[i] = L;
} else {
j = max(0, len - i);
while(ch[j] == ch[i + j] && i + j < m) j ++;
ex_next[i] = j;
k = i;
}
}
}
void get_ans(char t[], char s[]) {
memset(ans, 0, sizeof(ans));
int m = strlen(t), n = strlen(s);
int j = 0, k = 0;
while(s[j] == t[j]) j ++;
ans[0] = j;
for(int i = 1; i < n; i ++) {
int len = k + ans[k], L = ex_next[i - k];
if( L < len - i) {
ans[i] = L;
} else {
j = max(0, len - i);
while(t[j] == s[i + j] && i + j < n) j ++;
ans[i] = j;
k = i;
}
}
best = -1;
for(int i = 0; i < n; i ++) {
if(best < ans[i])
best = ans[i];
}
}
char str[5005][305];
int main() {
int n;
while(scanf("%d", &n), n) {
for(int i = 0; i < n; i ++) {
scanf("%s", &str[i]);
}
int L = strlen(str[0]);
maxlen = -1, pos = 0;
for(int i = 0; i < L; i ++) {
int tbest = 1<<20;
get_ex_next(str[0] + i);
for(int j = 1; j < n; j ++) {
get_ans(str[0] + i, str[j]);
if(tbest > best) tbest = best;
}
if(tbest >= maxlen) {
int flag = 0;
if(tbest > maxlen) flag = -1;
if(tbest == maxlen) {
for(int j = 0; j < tbest; j ++) {
if(str[0][i + j] < str[0][pos + j])
flag = -1;
else if(str[0][j + i] > str[0][pos + j])
flag = 1;
if(flag != 0) break;
}
}
maxlen = tbest;
if(flag <= 0) {
pos = i;
}
}
}
if(maxlen > 0) {
str[0][pos+maxlen] = 0;
puts(str[0] + pos);
} else {
puts("IDENTITY LOST");
}
}
}