s=eval("raw_input(),"*100) for a in s: p=0 for b in s: while a[:p]==b[:p]and a!=b:p+=1 print a[:p]