main=interact$head.foldr(#)[[]].lines x#(y:z)=zipWith(:)x(z++repeat y)