m@main=do a:x<-g;b:y<-g;putStrLn$[n|(n,s,t)<-zip3['1'..]x y,s==a,t==b]++' ':a++b;m g=fmap words getLine