m@main=getLine>>=putStrLn.f.span(>' ')>>m f(a,s:b)=do(x,c)<-zip[0..]b;[s|elem x$read$'[':a++"]"]++[c]