def partition():
global n, sum, stack
sum = 0
n = int(input("n="))
stack = [0]*(n+1)
def init(level):
if level == 1:
stack[level] = 0
else:
stack[level] = stack[level-1] - 1
def succ(level) -> bool:
global sum
if stack[level] < n - sum:
stack[level] +=1
return True
else:
sum -= stack[level-1]
return False
def valid(level) -> bool:
global sum
if stack[level] <= n - sum:
sum += stack[level]
return True
return False
def sol(level) -> bool:
return sum == n
def printf(level):
global sum
for i in range(1, level+1):
print(stack[i], end = " ")
print()
sum -= stack[level]
def solve(level):
init(level)
while succ(level) is True:
if valid(level) == True:
if sol(level) == True:
printf(level)
else:
solve(level+1)
solve(1)
partition()
ZGVmIHBhcnRpdGlvbigpOgogICAgZ2xvYmFsIG4sIHN1bSwgc3RhY2sKICAgIHN1bSA9IDAKICAgIG4gPSBpbnQoaW5wdXQoIm49IikpCiAgICBzdGFjayA9IFswXSoobisxKQoKICAgIGRlZiBpbml0KGxldmVsKToKICAgICAgICBpZiBsZXZlbCA9PSAxOgogICAgICAgICAgICBzdGFja1tsZXZlbF0gPSAwCiAgICAgICAgZWxzZToKICAgICAgICAgICAgc3RhY2tbbGV2ZWxdID0gc3RhY2tbbGV2ZWwtMV0gLSAxCiAgICBkZWYgc3VjYyhsZXZlbCkgLT4gYm9vbDoKCiAgICAgICAgZ2xvYmFsIHN1bQogICAgICAgIGlmIHN0YWNrW2xldmVsXSA8IG4gLSBzdW06CiAgICAgICAgICAgIHN0YWNrW2xldmVsXSArPTEKICAgICAgICAgICAgcmV0dXJuIFRydWUKICAgICAgICBlbHNlOgogICAgICAgICAgICBzdW0gLT0gc3RhY2tbbGV2ZWwtMV0KICAgICAgICAgICAgcmV0dXJuIEZhbHNlCgogICAgZGVmIHZhbGlkKGxldmVsKSAtPiBib29sOgogICAgICAgIGdsb2JhbCBzdW0KICAgICAgICBpZiBzdGFja1tsZXZlbF0gPD0gbiAtIHN1bToKICAgICAgICAgICAgc3VtICs9IHN0YWNrW2xldmVsXQogICAgICAgICAgICByZXR1cm4gVHJ1ZQogICAgICAgIHJldHVybiBGYWxzZQoKICAgIGRlZiBzb2wobGV2ZWwpIC0+IGJvb2w6CiAgICAgICAgcmV0dXJuIHN1bSA9PSBuCgogICAgZGVmIHByaW50ZihsZXZlbCk6CiAgICAgICAgZ2xvYmFsIHN1bQogICAgICAgIGZvciBpIGluIHJhbmdlKDEsIGxldmVsKzEpOgogICAgICAgICAgICBwcmludChzdGFja1tpXSwgZW5kID0gIiAiKQogICAgICAgIHByaW50KCkKICAgICAgICBzdW0gLT0gc3RhY2tbbGV2ZWxdCgogICAgZGVmIHNvbHZlKGxldmVsKToKICAgICAgICBpbml0KGxldmVsKQogICAgICAgIHdoaWxlIHN1Y2MobGV2ZWwpIGlzIFRydWU6CiAgICAgICAgICAgIGlmIHZhbGlkKGxldmVsKSA9PSBUcnVlOgogICAgICAgICAgICAgICAgaWYgc29sKGxldmVsKSA9PSBUcnVlOgogICAgICAgICAgICAgICAgICAgIHByaW50ZihsZXZlbCkKICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgc29sdmUobGV2ZWwrMSkKICAgIHNvbHZlKDEpCnBhcnRpdGlvbigpCg==