from collections import defaultdict

import string

import sys

sys.setrecursionlimit(10 ** 7)

from functools import lru_cache



N = int(input())

alph = string.ascii_lowercase



ans = defaultdict(int)



@lru_cache(maxsize=None)

def search(S, nums):

    if nums in ans:

        return

    if len(nums) == N:

        ans[nums] = S

        return



    for i in range(len(nums)):

        for s, n in zip(S, nums):

            if n == i:

                search(S + s, nums + (n, ))

                break

    C = set(list(S))

    for s in alph:

        if not s in C:

            search(S + s, nums + (len(nums), ))

            break



search('a', (0, ))

ans = list(ans.values())

ans.sort()

print(*ans, sep='\n')

from collections import defaultdict

import string

import sys

sys.setrecursionlimit(10 ** 7)

from functools import lru_cache



N = int(eval(input()))

alph = string.ascii_lowercase



def search(S, mx):

    if len(S) == N:

        print(S)

    else:

        for s in alph[: mx + 1]:

            search(S + s, mx)

        search(S + alph[mx + 1], mx + 1)



search('a', 0)

from collections import defaultdict
import string
import sys

sys.setrecursionlimit(10**7)
from functools import lru_cache

N = int(input())
alph = string.ascii_lowercase
ans = defaultdict(int)


@lru_cache(maxsize=None)
def search(S, nums):
    if nums in ans:
        return
    if len(nums) == N:
        ans[nums] = S
        return
    for i in range(len(nums)):
        for s, n in zip(S, nums):
            if n == i:
                search(S + s, nums + (n,))
                break
    C = set(list(S))
    for s in alph:
        if not s in C:
            search(S + s, nums + (len(nums),))
            break


search("a", (0,))
ans = list(ans.values())
ans.sort()
print(*ans, sep="\n")

from collections import defaultdict
import string
import sys

sys.setrecursionlimit(10**7)
from functools import lru_cache

N = int(eval(input()))
alph = string.ascii_lowercase


def search(S, mx):
    if len(S) == N:
        print(S)
    else:
        for s in alph[: mx + 1]:
            search(S + s, mx)
        search(S + alph[mx + 1], mx + 1)


search("a", 0)

-N = int(input()) +N = int(eval(input())) -ans = defaultdict(int) -@lru_cache(maxsize=None) -def search(S, nums): -    if nums in ans: -        return -    if len(nums) == N: -        ans[nums] = S -        return -    for i in range(len(nums)): -        for s, n in zip(S, nums): -            if n == i: -                search(S + s, nums + (n,)) -                break -    C = set(list(S)) -    for s in alph: -        if not s in C: -            search(S + s, nums + (len(nums),)) -            break +def search(S, mx): +    if len(S) == N: +        print(S) +    else: +        for s in alph[: mx + 1]: +            search(S + s, mx) +        search(S + alph[mx + 1], mx + 1) -search("a", (0,)) -ans = list(ans.values()) -ans.sort() -print(*ans, sep="\n") +search("a", 0)