def f(n, r)
  unless $memo[n][r]
    $memo[n][r] = f(n - 1, r - 1).map{|i|i + [1]}
    $memo[n][r] += f(n - r, r).map{|i|i.map{|j|j + 1}} if n >= 2 * r
  end
  return $memo[n][r]
end
def main(input = STDIN)
  while (n = input.gets.to_i) != 0
    $memo = Array.new(n + 1){|i|[[[0]], [[i]]]}
    arr = []
    (1..n).each{|i|arr += f(n, i)}
    puts arr.sort.reverse.map{|i|i.join(" ")}
  end
end
main