def main():

    from collections import deque

    from operator import itemgetter

    from string import ascii_lowercase



    N = int(input())



    deq = deque(), deque()

    curr = 0

    deq[curr].append(('a', 0))  # (word,largest_char_index)

    for _ in range(N - 1):

        while deq[curr]:

            word, largest_char_index = deq[curr].popleft()

            for add_char_index in range(largest_char_index + 1 + 1):

                new_word = word + ascii_lowercase[add_char_index]

                deq[curr ^ 1].append(

                    (new_word, max(largest_char_index, add_char_index)))

        curr ^= 1



    print(*map(itemgetter(0), deq[curr]), sep='\n')





if __name__ == '__main__':

    main()

def main():

    from string import ascii_lowercase



    N = int(input())



    ans = []



    def dfs(s='a', ma='a'):

        if len(s) == N:

            ans.append(s)

            return



        for c in ascii_lowercase:

            dfs(s + c, max(c, ma))

            if c > ma: break



    dfs()



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





if __name__ == '__main__':

    main()

def main():
    from collections import deque
    from operator import itemgetter
    from string import ascii_lowercase

    N = int(input())
    deq = deque(), deque()
    curr = 0
    deq[curr].append(("a", 0))  # (word,largest_char_index)
    for _ in range(N - 1):
        while deq[curr]:
            word, largest_char_index = deq[curr].popleft()
            for add_char_index in range(largest_char_index + 1 + 1):
                new_word = word + ascii_lowercase[add_char_index]
                deq[curr ^ 1].append(
                    (new_word, max(largest_char_index, add_char_index))
                )
        curr ^= 1
    print(*map(itemgetter(0), deq[curr]), sep="\n")


if __name__ == "__main__":
    main()

def main():
    from string import ascii_lowercase

    N = int(input())
    ans = []

    def dfs(s="a", ma="a"):
        if len(s) == N:
            ans.append(s)
            return
        for c in ascii_lowercase:
            dfs(s + c, max(c, ma))
            if c > ma:
                break

    dfs()
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

-    from collections import deque -    from operator import itemgetter -    deq = deque(), deque() -    curr = 0 -    deq[curr].append(("a", 0))  # (word,largest_char_index) -    for _ in range(N - 1): -        while deq[curr]: -            word, largest_char_index = deq[curr].popleft() -            for add_char_index in range(largest_char_index + 1 + 1): -                new_word = word + ascii_lowercase[add_char_index] -                deq[curr ^ 1].append( -                    (new_word, max(largest_char_index, add_char_index)) -                ) -        curr ^= 1 -    print(*map(itemgetter(0), deq[curr]), sep="\n") +    ans = [] + +    def dfs(s="a", ma="a"): +        if len(s) == N: +            ans.append(s) +            return +        for c in ascii_lowercase: +            dfs(s + c, max(c, ma)) +            if c > ma: +                break + +    dfs() +    print(*ans, sep="\n")