def solve():

    ans = []

    def square(n, rest, limit):

        if rest == 0:

            print((*ans))

        else:

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

                if i > limit:

                    continue

                ans.append(i)

                square(n, rest - i, i)

                ans.pop()

    

    import sys

    for n in map(int, sys.stdin.readlines()):

        if n == 0:

            break

        square(n, n, n)



solve()

def solve():

    answers = []

    def square(ans, rest, limit):

        if rest == 0:

            answers.append(' '.join(map(str, ans)))

        else:

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

                if i > limit:

                    continue

                square(ans + [i], rest - i, i)

    

    import sys

    for n in map(int, sys.stdin):

        if n == 0:

            break

        square([], n, n)

    

    print(('\n'.join(answers)))



solve()

def solve():
    ans = []

    def square(n, rest, limit):
        if rest == 0:
            print((*ans))
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                ans.append(i)
                square(n, rest - i, i)
                ans.pop()

    import sys

    for n in map(int, sys.stdin.readlines()):
        if n == 0:
            break
        square(n, n, n)


solve()

def solve():
    answers = []

    def square(ans, rest, limit):
        if rest == 0:
            answers.append(" ".join(map(str, ans)))
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                square(ans + [i], rest - i, i)

    import sys

    for n in map(int, sys.stdin):
        if n == 0:
            break
        square([], n, n)
    print(("\n".join(answers)))


solve()

-    ans = [] +    answers = [] -    def square(n, rest, limit): +    def square(ans, rest, limit): -            print((*ans)) +            answers.append(" ".join(map(str, ans))) -                ans.append(i) -                square(n, rest - i, i) -                ans.pop() +                square(ans + [i], rest - i, i) -    for n in map(int, sys.stdin.readlines()): +    for n in map(int, sys.stdin): -        square(n, n, n) +        square([], n, n) +    print(("\n".join(answers)))