peterverebics/CodeNet_Python_118 huggingface dataset:
def next(S='a'):
    idx = len(S)
    cnt = len(set(list(S)))
    if idx == N:
        print(S)
        return
    for i in range(min(N,idx)+1):
        if cnt < i:
            break
        next(S +ls[i])


N = int(input())
ls = ['a','b','c','d','e','f','g','h','i','j']
next()
n = int(input())
s = "abcdefghij"
def func(a):
  if len(a) == n:
    print(a)
  else:
    for i in range(len(set(a))+1):
      func(a+s[i])
func("a")
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d

n = int(input())

def dfs(s, mx, path):
    if n == len(s):
        path.append(s)
        return
    for i in range(ord('a'), mx + 1):
        if i == mx:
            dfs(s + chr(i), mx + 1, path)
        else:
            dfs(s + chr(i), mx, path)

path = []
dfs('', ord('a'), path)
path.sort()
for ans in path:
    print(ans)
n=int(input())

def f(i, s, n):
	if i==n:
		print(s)
		return
	x=len(set(s))
	for j in range(x+1):
		f(i+1, s+chr(j+97), n)
		
f(0,"",n)
n = int(input())

t = []
c = 'abcdefghij'

def f(s, d, m):
  if d == 0:
    t.append(s)
    return
  
  for k in range(m+1):
    f(s*10 + k, d-1, m+1 if k==m else m)
    
f(0, n, 0)

for i in t:
  x = []
  for j in range(n):
    x.append(c[i // 10**(n-j-1) % 10])
  print(''.join(x))
from collections import *

def dfs(now):
    if len(now)==N:
        print(''.join(now))
        return

    for i in range(ord(max(now))-ord('a')+2):
        now.append(alpha[i])
        dfs(now)
        now.pop()

N = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
dfs(deque(['a']))
a = int(input())
S = 'abcdefghij'

def dfs(s,c):
    if c == a:
        ans.append(s)
        return 
    for i in S[:c+1]:
        if i in s:dfs(s+i,c+1)
        else:
            dfs(s+i,c+1)
            return 
ans = []

dfs("",0)

for i in ans:
    print(i)
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def dfs(m, N):
    if N == 0:
        yield []
    else:
        for i in range(0, m+2):
            for solution in dfs(max(m, i), N-1):
                yield [i]+solution

def solve():
    '''
    a
    '''
    N = read_int()
    alphabets = 'abcdefghij'
    for solution in dfs(-1, N):
        print(''.join(alphabets[i] for i in solution))


if __name__ == '__main__':
    solve()
N = int(input())
char = "abcdefghij"
prev = ["a"]
results = []
for i in range(N-1):
  results = []
  for p in prev:
    for j in range(len(set(p))+1):
      results.append(p+char[j])
  prev = results
if N == 1:
  print("\n".join(prev))
else:
  print("\n".join(results))
N = int(input())

def dfs(s, mx):
    if len(s) == N:
        print(s)
    else:
        for c in range(ord("a"),mx+1):
            if c == mx:
                dfs(s+chr(c),mx+1)
            else:
                dfs(s+chr(c),mx)

dfs("",ord("a"))
L=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i','j']
L_ind = [i for i in range(10)]
N=int(input())
K=[]
for i in range(N):
    if i==0:
        K.append(str(L_ind[0]))
    else:
        K_ = []
        for j in K:
            for m in range(int(max(set(j)))+2):
                K_.append(j + str(L_ind[m]))
        K = K_
    
for k in K:
    ans = ''
    for i in k:
        ans += L[int(i)]
    print(ans)
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])

    ret = []
    stack = [('', ord('a'))]
    while stack:
        s, c = stack.pop()
        if len(s) == n:
            ret.append(s)
        else:
            for x in range(ord('a'), c+1):
                stack.append((s+chr(x), c+1 if c == x else c))

    return '\n'.join(sorted(ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
n = map(int, raw_input().split(' '))[0]

def dfs(i, mx, n, cur = []):
	if i==n:
		print ''.join(cur)
		return
	for v in range(0, mx + 1): dfs(i + 1, mx + (1 if v == mx else 0), n , cur + [chr(v+ ord('a'))])

dfs(0,0,n)
n = int(input())
r = 'a',
for _ in range(n - 1):
  r = [s + c for s in r for c in set(s + chr(ord(max(s)) + 1))]
print(*sorted(r), sep='\n')
# パナソニック2020D
import sys
write = lambda x: sys.stdout.write(x+"\n")
from queue import deque
n = int(input())
q = deque([("a", "a")])
while True:
    s, m = q.pop()
    if len(s)==n:
        write(s)
    elif len(s)>=n+1:
        break
    for o in range(ord("a"), ord(m)+2):
        if ord(m)<o:
            m = chr(o)
        q.appendleft((s + chr(o), m))
def solve():
    N = int(input())
    dfs("", 0, N)

def dfs(cur, n_type, N):
    if len(cur) == N:
        print(cur)
        return
    
    for offset in range(n_type+1):
        next_chr = chr(ord('a') + offset)
        next_n_type = n_type + 1 if offset==n_type else n_type
        dfs(cur+next_chr, next_n_type, N)
    
    return
if __name__ == '__main__':
    solve()
N=int(input())
S='abcdefghijklmnopqrstuvwxyz'
A=['a']
for _ in range(N-1):
    now=[]
    for a in A:
        b=sorted(list(a))[-1]
        bi=S.index(b)
        for i in range(bi+2):
            now.append(a+S[i])
    A=now.copy()
A.sort()
for a in A:
    print(a)
def DFS(word,n):
    if len(word)==N:
        return print(word)
    else:
        for i in range(n+1):
            DFS(word+chr(97+i),n+1 if i==n else n)


N=int(input())
DFS("",0)
N = int(input())
alp = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

def dfs(s, n):
    if len(s) == N:
        print(s)
        return
    for i in range(n+1):
        dfs(s+alp[i], max(n, i+1))

dfs("", 0)
def main():
    N = int(input())
    ans = ['a']
    i = 0
    while i != N-1:
        tmp = set()
        i += 1
        for j in range(len(ans)):
            for k in range(i+1):
                tmp.add(ans[j]+chr(97+k))
                if chr(97+k) not in ans[j]:
                    break
        ans = list(tmp)
    ans.sort()
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()
N = int(input())

ans = ['a']
for i in range(N-1):
    tmp = []
    for s in ans:
        m = max(s)
        j = ord(m) - ord('a') + 1
        for k in range(j+1):
            tmp.append(s + chr(ord('a') + k))
    ans = tmp
print(*ans, sep='\n')
a='a'
for _ in range(int(input())-1):
  a=[s+c for s in a for c in sorted(set(s+chr(ord(max(s))+1)))]
print(*a,sep='\n')
def generator(n):
    if n == 1:
        yield [0]
    else:
        for A in generator(n - 1):
            for i in range(max(A) + 2):
                A.append(i)
                yield A
                A.pop()


n = int(input())
for A in generator(n):
    print(''.join([chr(a + 97) for a in A]))
# D - String Equivalence 
def dfs(s, mx):
    if len(s)==n:
        print(s)
        return
    for c in range(ord('a'),ord(mx)+1):
        dfs(s+chr(c),(chr(ord(mx)+1) if ord(mx)==c else mx))

n=int(input())
dfs('','a')
N = int(input())
ASC = 97

def dfs(s, mx):
    if len(s) == N:
        print(s)
        return
    for c in range(ASC, mx+2):
        t = s + chr(c)
        dfs(t, max(mx, c))
    
s = 'a'
mx = ord(s)
dfs(s, mx)
n = int(input())

ans = ["a"]

for i in range(n-1):
    old = ans
    ans = []
    for t in old:
        k = len(set(list(t)))
        for j in range(k+1):
            ans.append(t+chr(97+j))

print("\n".join(ans))
def dfs(word, N):
    if len(word) == N:
        print(word)
    else:
        for i in range(len(set(word))+1):
            dfs(word + chr(97+i), N)


def main():
    N = int(input())
    dfs('a', N)


if __name__ == "__main__":
    main()
n = int(input())
s = [('', 0)]
cnt = 0
ans = []
while s:
    t, k = s.pop()
    if len(t) == n:
        print(t)
    else:
        s.append((t + chr(k + 97), k + 1))
        for i in range(k - 1, -1, -1):
            s.append((t + chr(i + 97), k))
c = 'abcdefghij'

def join(s, k, n):
    if len(s) == n:
        return [s]
    ans = []
    for i in range(k):
        ans += join(s + c[i], k, n)
    ans += join(s + c[k], k + 1, n)
    return ans

n = int(input())
ans = join('', 0, n)
for x in ans:
    print(x)
import sys
sys.setrecursionlimit(10**7)
n = int(input())

def dfs(s):
    if len(s) == n:
        print(s)
    else:
        for x in map(chr, range(97, ord(max(s))+2)):
            dfs(s+x)


dfs("a")
n = int(input())
a = ord("a")

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for i in range(a, mx + 2):
            if i != mx + 1:
                dfs(s + chr(i), mx)
            else:
                dfs(s + chr(i), mx + 1)

dfs("a", a)
al = list("abcdefghij")
n = int(input())
w = [0 for i in range(n)]
w[-1] = -1
la = list(range(n))
while (w != la):
  w[-1] += 1
  for i in range(n-1):
    i = n-i-1
    z = False
    for j in range(n):
      if i != j and w[j] == w[i]:
        z = True
    if (not z) and (not (w[i]-1 in w)):
      w[i] = 0
      w[i-1] += 1
  c = [al[w[i]] for i in range(n)]
  print("".join(c))
def dfs(s,mx):
  if len(s)==n:
    print(s)
    return
  for c in range(ord("a"),ord(mx)+1):
    dfs(s+chr(c),chr(ord(mx)+1) if ord(mx)==c else mx)

n=int(input())
dfs("","a")
n = int(input())
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
    B = []
    for a in A:
        for s in S[:len(set(a)) + 1]:
            B.append(a + s)
    A = B[::]
print('\n'.join(A))
from collections import deque

N = int(input())
if N == 1:
  print('a')
  exit()

h = deque(['a'])

while h:
  s = h.pop()
  if len(s) == N:
    print(s)
  else:
    a = set([])
    for i in s:
      a.add(i)
    for i in range(len(a),-1,-1):
      h.append(s+chr(ord('a')+i))
import string

def generate(n, res, cur = None, alphabet = None):
    if cur is None:
        cur = []
    if alphabet is None:
        alphabet = list(string.ascii_lowercase)[::-1]
    if n == 0:
        res.append(''.join(cur))
        return
    for i in range(len(cur)):
        cur.append(cur[i])
        generate(n - 1, res, cur, alphabet)
        cur.pop()
    cur.append(alphabet.pop())
    generate(n - 1, res, cur, alphabet)
    alphabet.append(cur.pop())

res = []
generate(int(input()), res=res)
res = sorted(set(res))
for row in res:
    print(row)
# ret = []
N = int(input())
newL = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    L = newL.copy()
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))
N = int(input())

A = [chr(ord("a") + i) for i in range(26)]


def dfs(S, i):
    if len(S) == N:
        print(S)
        return
    for j in range(i):
        dfs(S + A[j], i)
    dfs(S + A[i], i + 1)


dfs("", 0)
N = int(input())

a_num = 97

def dfs(s, n, cnt): #s: 現在の文字列, n: 残りの文字数, cnt: 現在の文字列の最大の値
    if n == 0:
        print(s)
        return
    for i in range(cnt+2):
        if i == cnt+1:
            dfs(s+chr(a_num+i), n-1, cnt+1)
        else:
            dfs(s+chr(a_num+i), n-1, cnt)

dfs("a", N-1, 0)
import sys
sys.setrecursionlimit(1000000)

N = int(input())
alpha = [chr(ord('a') + i) for i in range(26)]

def dfs(s, max_i):
  if len(s) == N:
    print(s)
  else:
    for i in range(97,max_i+1):
      dfs(s+chr(i), max(max_i, i+1))

dfs('', 97)
n=int(input())

def f(idx, mx, str):
    # print(idx, mx, str)
    if idx==n:
        print(str)
        return
    for i in range(mx+1+1):
        f(idx+1, max(i, mx), str+chr(ord('a')+i))

f(0,-1,"")
import sys
import re

l = sys.stdin.readline()
l = int(l)
out = []
def x(stri,l,depth):
  str = 'abcdefghij'
  use = 0
  for i in range(0,l-depth+1):
    if( use == 1):
      break
    cdepth = depth
    cstri = stri
    if ( str[i] not in cstri):
      use = 1
    cstri += str[i] 
    cdepth -= 1
    if( cdepth == 0):
	out.append(cstri)
    else:
	x(cstri,l,cdepth)


stri = 'a'
if( l == 1):
 print stri
 exit(0)
x(stri,l,l-1)

count = 0
for i in out:
  print i


sys.stdout.flush()
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()

ANS = [[] for _ in range(N+1)]

for i in range(1,N+1):
    if i == 1:
        ANS[i].append('a')
    else:
        for a in ANS[i-1]:
            for j in range(97,ord(max(a[k] for k in range(i-1)))+2):
                ANS[i].append(a+chr(j))
print(*ANS[N],sep='\n')
N = int(input())

def ww(s, sn, ans,n):
    global N 
    if n == N:
        ans.append(s)
        return 0
    n += 1
    for i in range(sn+1):
        if i == sn:  
            ww(s+chr(ord("a")+i), sn+1, ans, n)
        else:
            ww(s+chr(ord("a")+i), sn, ans, n)
ans = []
ww("a", 1, ans, 1)

ans.sort()

for i in ans:
    print(i)
n=int(input())



ans=[[] for i in range(10)]


for i in range(n):
    if i==0:
        ans[i].append(["a",1])
    else:
        for moji,index in ans[i-1]:
            for plus in range(index):
                new=moji+chr(plus+97)
                ans[i].append([new,index])
            new=moji+chr(index+97)
            ans[i].append([new,index+1])

for a,b in ans[n-1]:
    print(a)
n = int(input())


def max2(s):
    return max(map(lambda c: ord(c) - ord('a'), s))


ans = ['a']
for _ in range(n - 1):
    ans2 = []
    for a in ans:
        for i in range(max2(a) + 2):
            ans2.append(a + chr(i + ord('a')))
    ans = ans2

for a in ans:
    print(a)
N = int(input())
def dfs(s):
  if len(s) == N:
    print(s)
    return
  else:
    for i in range(ord("a"), ord("z")+1):
      if max(list(s)) != chr(i-2):
        dfs(s+chr(i))
      else:
        return
dfs("a")
N = int(input())

def it(remain,n):
    if remain == 0:
        yield []
    else:
        for x in range(n+1):
            for d in it(remain-1,max(x+1,n)):
                d.append(x)
                yield d


print(*(''.join(chr(x+ord('a')) for x in reversed(d)) for d in it(N,0)), sep='\n')
N=int(input())
A=[]
B=[[] for i in range(N+1)]
B[0].append("")
for i in range(N):
    A.append(chr(97+i))
    for j in B[i]:
        for k in A:
            B[i+1].append(j+k)
for i in B[N]:
    count=ord("a")
    yes=1
    for j in range(N):
        if ord(i[j])<=count+1:
            count=max(count,ord(i[j]))
        else:
            yes=0
            continue;
    if yes==1:
        print(i)
def dfs(s, mx, n):
    if len(s) == n:
        print(s)
        return

    c = 'a'
    while c <= mx:
        nmx = mx
        if c == mx:
            nmx = chr(ord(c) + 1)
        dfs(s + c, nmx, n)
        c = chr(ord(c) + 1)

n = int(input())
dfs("", 'a', n)
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())

# s: 文字列
# n: これまでに使用した文字の種類数
def dfs(s:str, n:int):
    if len(s) == N:
        print(s)
        return
    
    maxc = ord("a") + n

    for c in range(ord("a"),  maxc + 1):
        dfs(s + chr(c), n+1 if (c == maxc) else n)

def main():
    dfs("", 0)

if __name__ == '__main__':
    main()
N = int(input())

result = ["a"]
alph = "abcdefghijklmn"

def gen(w):
    ret = []
    s = len(set(w))
    for ch in alph[:s+1]:
        ret.append(w+ch)
    return ret

i = 0
w = result[i]
while len(w) <= N:
    w = result[i]
    result.extend(gen(w))
    i += 1
    if len(w) == N:
        print(w)
N = int(input())

alph = [chr(ord('a') + i)  for i in range(N)]
S = ""
ans = []


# i文字目に何を入れるか　j種類使っている状態
def add_s(S, j):

    if len(S) == N:
        ans.append(S)
        print(S)
        return

    for s in range(j+2):
        S += alph[s]
        if s == j+1:
            add_s(S, j+1)
        else:
            add_s(S, j)
        S = S[:-1]

add_s("a", 0)
# -*- coding: utf-8 -*-

alphabets = list('abcdefghijklmnopqrstuvwxyz')

N = int(input())

if N == 1:
    print('a')
else:
    tmp = ['a']
    for i in range(1, N):
        result = []
        for s in tmp:
            alpha_list = sorted(list(set(list(s))))
            for a in alpha_list:
                result.append(s+a)
            result.append(s+alphabets[len(set(list(s)))])
            tmp = result
    print('\n'.join(result))
import string
al = string.ascii_lowercase
N = int(input())

def dfs(s, mx):
    if len(s) == N:
        print(s)
    else:
        for i in range(mx):
            c = al[i]
            if c == al[mx-1]:
                dfs(s+c, mx+1)
            else:
                dfs(s + c, mx)

dfs('', 1)
n = int(input())
alp = [chr(i + 97) for i in range(26)]

ans = [[] for _ in range(n)]
ans[0] = ['a']
for i in range(1, n):
    for j in ans[i - 1]:
        for k in range(len(set(j)) + 1):
            ans[i].append(j + alp[k])
print(*ans[n - 1], sep='\n')
import sys

input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 8)

N = int(input())


def dfs(s, mx):
    if len(s) == N:
        print(s)
        return
    for c in range(ord("a"), mx + 2):
        t = s
        t += chr(c)
        dfs(t, max(c, mx))


dfs("", ord("a") - 1)
# D
N = int(input())

al = [chr(ord('a') + i) for i in range(26)]

def dfs(S, i):
    if len(S) == N:
        yield S
        return
    for j in range(i):
        for w in dfs(S + al[j], i):
            yield w
    for w in dfs(S + al[i], i + 1):
        yield w

for w in dfs('', 0):
    print(w)
N = int(input())

chars = [chr(i) for i in range(ord('a'), ord('z')+1)]

def dfs(s, mx):
    if len(s) == N:
        print(s)
    else:
        # a, b, c ..., mx
        for i in range(ord('a'), mx+1):
            ns = s + chr(i)
            if i == mx:
                nmx = i + 1
            else:
                nmx = mx

            dfs(ns, nmx)


dfs("", ord('a'))
n = int(input())
from copy import copy

L = ["a"]
if n == 1:
    print(L[0])
    exit()
    
for i in range(n-1):
    li = []
    for s in L:
        max1 = max(s)
        S = ""
        for j in range(ord(max1)-95):
            S = s + chr(97+j)
            #print(ord(max1)-95,chr(ord(max1)+j))
            li.append(S)
    L = copy(li)
    
print("\n".join(L))
n=int(input())
l=[['a1']]+[[] for _ in range(9)]
for i in range(9):
  for b in l[i]:
    t=b[-1]
    for p in range(int(t)):
      l[i+1].append(b[:-1]+chr(97+p)+t)
    l[i+1].append(b[:-1]+chr(97+int(t))+str(int(t)+1))
for i in l[n-1]:
  if len(i)==12:
    print(i[:-2])
  else:
    print(i[:-1])
from collections import defaultdict
n=int(input())
al=[chr(ord('a') + i) for i in range(26)]
norm=defaultdict(list)
def max_al(s):
  tmp=0
  for i in range(len(s)):
    tmp2=al.index(s[i])
    tmp=max(tmp,tmp2)
  return tmp

for i in range(11):
  if i==0:
    norm[1]=['a']
  else:
    for char in norm[i-1]:
      range_digit=max_al(char)+2
      for s in al[0:range_digit]:
        norm[i].append(char+s)

for char in norm[n]:
  print(char)
def sol(k):

    def gen(d, cur, s):
        if d == k:
            yield s
            return
        for i in range(0, cur+1):
            yield from gen(d+1, max(cur, i+1), s+chr(97+i))

    return gen(0, 0, '')

def main():
    k = int(input())
    for x in sol(k):
        print(x)

if __name__ == '__main__':
    main()
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N = int(input())

chars = "abcdefghij"

queue = deque()
queue.append(('a', 1))

ans = []

while queue:
    s, num = queue.popleft()
    if len(s) == N:
        print(s)
    else:
        for i in range(num+1):
            ss = s + chars[i]
            if i == num:
                queue.append((ss, num+1))
            else:
                queue.append((ss, num))
n = int(input())
alp = ["a","b","c","d","e","f","g","h","i","j"]
ans = []
cnt = 0
def dfs_rec(prev,cnt): # prev は前までの文字列 cntは文字種数を持つ
    if len(prev) == n:
        ans.append("".join(prev))
        return
    for i in range(cnt+1):
        dfs_rec(prev+[alp[i]],cnt+(i//cnt)) # この再帰呼び出しの際にprevが書き換わる？


dfs_rec(["a"],1)
ans.sort()
for s in ans:
    print(s)
N = int(input())
az = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def norm(n, in_list):
	out_list = []
	for line in in_list:
		for i in range(len(set(line))+1):
			new_line = line + az[i]
			out_list.append(new_line)
	return out_list
init_line = ['a']
for _ in range(N-1):
	init_line = norm(1, init_line)
for line in init_line:
	print(line)
n = int(input())

if n==1:
    print("a")
    exit()

alp = "abcdefghijklmnopqrstuvwxyz"

def next(s,n):
    if n==0:
        print(s)
        return
    val = len(set(s)) # 1 => only a, 2=> a and b
    for i in range(val+1):
        next(s + alp[i],n-1)

s="a"
next(s,n-1)
import sys
sys.setrecursionlimit(10**6)
N = int(input())

s = 'abcdefghijklmn'

ans = []
def f(t, k, n):
    if n == N:
        ans.append(t)
        return
    for i in range(k+1):
        f(t+s[i], max(k,i+1), n+1)

f('a', 1, 1)

for a in ans:
    print(a)
def comb(current, mx, target: int):
    if len(current) == target:
        yield current
    elif len(current) < target and len(alphabet) > 0:
        for i in range(mx + 1):
            yield from comb(current + [chr(i + 97)], mx + 1 if i == mx else mx, target)


if __name__ == '__main__':
    n = int(input())
    alphabet = [str(chr(i)) for i in range(97, 97 + 26)]
    result = set()

    for perm in comb([], 0, n):
        print("".join(perm))
n = int(input())
s = 'abcdefghij'


def dfs(ans, ref):
    if len(ans) == n:
        print(ans)
    else:
        l = [s[i] for i in range(ref + 1)]
        for x in l:
            if x == l[ref]:
                dfs(ans + x, ref + 1)
            else:
                dfs(ans + x, ref)


dfs('', 0)
def DFS(word,N):
    if len(word)==n:print(word)
    else:
        for i in range(N+1):
            DFS(word+chr(97+i),N+1 if i==N else N)


n=int(input())
DFS("",0)
def main():
    n = int(input())

    ans = []

    def fanc(i, s):
        if len(s) == n:
            ans.append(s)
        else:
            for x in range(i + 2):
                # print(x,i,s)
                fanc(max([x, i]), s + chr(97 + x))
                # fanc(x + 1, s + chr(97 + x))

    fanc(0, "a")
    ans.sort()
    for i in ans:
        print(i)

    # print(len(ans))
main()
#x=今まで使った文字種数、→次はaとα個のもの。つまり1つふえる
import sys
sys.setrecursionlimit(4100000)
n=int(input())
def dfs(s, mx):
    if len(s)==n:
        print(s)
        return 0
    for i in range(ord('a'), mx+2):# ord('a')からmx+1までの数字を使いたい
        t=str(s)
        moji=str(chr(i))
        t+=moji
        dfs(t, max(mx, i))
dfs('',ord('a')-1)
n = int(input())
c = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


def dfs(k, s):
    if len(s) == n:
        print(s)
        return
    for i in range(k):
        dfs(k, s+c[i])
    dfs(k + 1, s + c[k])


dfs(1, 'a')
N = int(input())

def standard_string(N, st):
    if len(st) == N:
        print(st)
    elif st == "":
        standard_string(N, "a")
    else:
        for i in range(97, ord(max(st))+ 2):
            st += chr(i)
            standard_string(N, st)
            st = st[:-1]
standard_string(N, "")
n=int(input())
def make(floor,kind,name): #floor=何階層目か,kind=何種類使ってるか
    if floor==n+1: 
        print(name)
        return
    num=min(floor,kind+1)
    for i in range(num):
        use=0 #新しい文字使ってるか
        if kind-1<i:
            use=1
        make(floor+1,kind+use,name+chr(i+97))
make(1,0,"")
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())

def rec(i, m, ar) :
  if i == N :
    print(''.join(chr(s + 97) for s in ar))
    return 
  for j in range(min(m + 1, N)) :
    rec(i + 1, max(m, j + 1), ar + [j])


rec(0, 0, [])
from collections import *

def dfs(l):
    if len(l)==N:
        print(''.join(l))
        return
    
    for a in range(ord('a'), ord(max(l))+2):
        l.append(chr(a))
        dfs(l)
        l.pop()
    
N = int(input())
dfs(deque(['a']))
ans=[]
N=int(input())
def saiki(A):
    eigo="abcdefghijklmnopqrstuvwxyz"
    if len(A)==N:
        B="".join(A)
        ans.append(B)
        return
    for i in range(len(set(A))+1):
        A.append(eigo[i%26])
        saiki(A)
        A.pop()
saiki([])
ans.sort()
for i in ans:
    print(*i,sep="")
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[chr(97+int(i)) for i in range(n)]

Ans=["a"]
if n>=2:
  for _ in range(n-1):
    Ans2=[]
    for a in Ans:
      s=set()
      for aa in a:
        s.add(aa)
      ss=len(s)
      for i in range(ss+1):
        Ans2.append(a+A[i])
    Ans=Ans2
Ans.sort()
for ans in Ans:
  print(ans)
def DFS(word,N):
    if len(word)==n:
        return print(word)
    else:
        for i in range(N+1):
            DFS(word+chr(97+i),N+1 if i==N else N)


n=int(input())
DFS("",0)