main=interact$f.lines f(a:x)=[t:[t|show s`elem`words a]|(s,t)<-zip[1..]x]>>=unlines