import List main=interact$unlines .tail .reverse .scanr(\r x->r:x ++[r])[]