main=interact$unlines.f.words f(x:y:s)=(x++" "):map((x>>" ")++)(map(:[])y++map(' ':)(f s)) f s=s