# -*- coding: utf-8 -*-

# Aizu 507

class Array
    def sum
        inject(0){|sum,i| sum+i}
    end

    def last
        if size > 0
            self[size-1]
        else
            nil
        end
    end
end

# 紙の枚数の制約
def check(result,value)
    if result.sum+value > $n
        return false
    else
        return true
    end
end

def backtrack(n,result)
    if result.sum == $n
        puts result.join(" ")
        return
    end
    n.times.map{|i| i+1}.reverse.each do |i|
        if result.size>0 && result.last<i
            next
        end
        if check(result,i)
            result << (i)
            backtrack(n-1,result)
            result.pop
        end
    end
end

while(true)
    $n = gets().to_i
    break if $n==0

    result = []
    backtrack($n,[])
end