main=getContents>>=mapM print.reverse.init.scanr(+)0.map read.lines