m@main=getLine>>=putStrLn.f>>m f[x]=[x] f(x:y)=last y:init y++[x]