Program ZadA_2;
var a,v:array[1..20] of string;
    n,br:0..20;
    i,j,k,l,p,p1,min,max:1..500;
    b:boolean;
    vir:string;

BEGIN
readln(n);
for i:=1 to n do
readln(a[i]);

min:=length(a[1]);
for i:=2 to n do
if min>length(a[i]) then min:=length(a[i]);

 k:=min div 10;
 l:=min div 2;
if k<1 then k:=1;
if l<1 then l:=1;

 b:=false;
 br:=0;
 for i:=k to l do
 for p:=1 to length(a[1])-i do
begin
 vir:=copy(a[1],p,i);
 begin
 for j:=2 to n do
 for p1:=1 to length(a[j])-i do
 if copy(a[j],p1,i)=vir then
   begin

   b:=true;
   p1:=length(a[j])-i;
   end
  else if p1=length(a[j])-i then
   begin
   b:=false;
   j:=n;
   end;

if b then
 begin
 br:=br+1;
 v[br]:=vir;
 end;
 end;

end;


max:=1;
 for i:=2 to br do
 if length(v[max])<length(v[i]) then max:=i;

 writeln;
 writeln(v[max]);

readln;
END.