a=eval(100*'raw_input(),') for s in a:print[s[:j+1]for j in range(99)for b in a if s[:j]==b[:j]and b!=s][-1]