l = [0 for i in range(31)]

pos = goal = 0

def solve(cur,sum):

    global pos, goal

    if cur == goal:

        print(" ".join(map(str,l[:pos])))

        return

    for i in range(sum,0,-1):

        if cur + i <= goal:

            l[pos] = i

            pos += 1

            solve(cur+i,i)

            pos -= 1

while True:

    goal = int(input())

    if goal==0: break

    solve(0,goal)
l = [0]*31

pos = goal = 0

def solve(cur,sum):

    global pos, goal

    if cur == goal:

        print(" ".join(map(str,l[:pos])))

        return

    for i in range(sum,0,-1):

        if cur + i <= goal:

            l[pos] = i

            pos += 1

            solve(cur+i,i)

            pos -= 1

while True:

    goal = int(input())

    if goal == 0: break

    solve(0,goal)
l = [0 for i in range(31)]
pos = goal = 0


def solve(cur, sum):
    global pos, goal
    if cur == goal:
        print(" ".join(map(str, l[:pos])))
        return
    for i in range(sum, 0, -1):
        if cur + i <= goal:
            l[pos] = i
            pos += 1
            solve(cur + i, i)
            pos -= 1


while True:
    goal = int(input())
    if goal == 0:
        break
    solve(0, goal)

l = [0] * 31
pos = goal = 0


def solve(cur, sum):
    global pos, goal
    if cur == goal:
        print(" ".join(map(str, l[:pos])))
        return
    for i in range(sum, 0, -1):
        if cur + i <= goal:
            l[pos] = i
            pos += 1
            solve(cur + i, i)
            pos -= 1


while True:
    goal = int(input())
    if goal == 0:
        break
    solve(0, goal)

-l = [0 for i in range(31)] +l = [0] * 31