def f(header, n, k, max)
    if k == 1
        puts header + n.to_s if n <= max
        return
    end

    [max, n-1].min.downto(1){|i|
        f(header + "#{i} ", n - i, k - 1, i)
    }
end

loop {
    n = gets.to_i
    break if n == 0
    (1..n).each{|k| f("", n, k, n)}
}