def square(from, max, parent = 0, out = '')
  from.downto(1) do |i|
    if i + parent > max
      next
    elsif i + parent == max
      print "#{i}\n"
    else
      print "#{i} "
      square(i, max, parent + i, out)
    end
  end
  out
end

while a = gets.to_i
  break if a == 0
  square(a, a)
end