main=getContents>>=mapM print.reverse.scanr1(+).map read.lines