p i=gets.to_i d="#{i-1}".split // while n=d.shift n.to_i.downto(1){|j|p j*10**d.size} end p 0