def solve():

    answers = [[] for i in range(31)]

    ans = []

    def square(n, rest, limit):

        if rest == 0:

            answers[n].append(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

        a = answers[n]

        if not a:

            square(n, n, n)

        for l in a:

            print((*l))



solve()

def solve():

    answers = []

    ans = []

    def square(n, rest, limit):

        if rest == 0:

            answers.append(' '.join(map(str, 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)

    

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



solve()

def solve():
    answers = [[] for i in range(31)]
    ans = []

    def square(n, rest, limit):
        if rest == 0:
            answers[n].append(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
        a = answers[n]
        if not a:
            square(n, n, n)
        for l in a:
            print((*l))


solve()

def solve():
    answers = []
    ans = []

    def square(n, rest, limit):
        if rest == 0:
            answers.append(" ".join(map(str, 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)
    print(("\n".join(answers)))


solve()

-    answers = [[] for i in range(31)] +    answers = [] -            answers[n].append(ans[:]) +            answers.append(" ".join(map(str, ans))) -        a = answers[n] -        if not a: -            square(n, n, n) -        for l in a: -            print((*l)) +        square(n, n, n) +    print(("\n".join(answers)))