m@main=getLine>>=putStrLn.foldl1(\s t->[(s>>c:filter(/=c)t)!!3|c<-s]).words>>m