i=open('../fd/0').readlines() for s in i: n=0 while len([t for t in i if t[:n]==s[:n]])>1:n+=1 print s[:n]