main=interact$(>>=unlines.f).lines f('d':' ':x)=f x!!0:f x f x=[x]