main=interact$unlines.s((((++"T").fst.span(<'T').s max).).zipWith max).lines s=scanl1