main=getContents>>=putStr.unlines.(\l->last l:init l).lines