while (n=gets.to_i) != 0 do
  puts n
  a = Array.new(n) {0}
  a[0] = n
  while a.last == 0 do
    i = a.index {|k| k == 1 || k == 0} - 1
    j = a.index {|k| k == 0} - 1
    a[i] -= 1
    if i == j
      a[i+1] += 1
    else
      l = j - i + 1
      m = 1
      a.fill(0,i+m)
      while l > 0 do
        a[i+m] = l > a[i] ? a[i] : l
        l -= a[i+m]
        m += 1
      end
    end
    puts (a.select {|k| k > 0}).join(" ")
  end
end