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

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

    def last
        return nil if self[0].nil?
        self[size-1]
    end
end

# 紙の枚数の制約
def check(state,value)
    if state.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[0].nil? && 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
    backtrack($n,[])
end