peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
ans = []
def bfs(s,tmp):
    if len(s)==n:
        ans.append(s)
        return
    for i in range(ord('a'),ord('a')+tmp+1):
        if i==ord('a')+tmp:
            bfs(s+chr(i),tmp+1)
        else:
            bfs(s+chr(i),tmp)
bfs('a',1)
print(*ans,sep='\n')
N = int(input())
def sub(l, d):
  if d == N:
    s = "".join(["abcdefghijklmnopqrstuvwxyz"[i] for i in l])
    print(s)
    return
  for j in range(max(l)+1+1):
    sub(l+[j], d+1)
sub([0], 1)
N = int(input())

char = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def search(arr):
  global N, char
  if len(arr) == N:
    ans = ''.join([char[x] for x in arr])
    print(ans)
    return
  else:
    for i in range(max(arr) + 2):
      arr_next = arr + [i]
      search(arr_next)

search([0])
import sys
rline = sys.stdin.readline

N = int(input())


def dfs(ans, max_c):
    if len(ans) == N:
        print(ans)
    else:
        for i in range(max_c + 1):
            dfs(ans + chr(ord('a') + i), max_c + 1 if i == max_c else max_c)


def solve():
    dfs('', 0)


if __name__ == '__main__':
    solve()
N=int(input())
L=['a','b','c','d','e','f','g','h','i','j']

Ans = [L[0]]
Backup = []

for k in range(N-1):
    Backup = Ans
    Ans = [i+L[j] for i in Backup for j in range(len(set(i))+1)]

for i in Ans:
    print(i)
def dfs(s, mx):
    if len(s) == n:
        print(s)
        return
    for i in range(ord('a'), mx + 2):
        dfs(s + chr(i), max(mx, i))


n = int(input())
dfs('', ord('a') - 1)
n = int(input())

def chrinc(s,n):
  return chr(ord(s)+1)

def dfs(s,mx):
  if len(s) == n:
    print(s)
  else:
    c = 'a'
    while c <= mx:
      dfs(s+c, chrinc(mx,1) if c==mx else mx)
      c = chrinc(c,1)

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

alp = [chr(i) for i in range(97, 97+26)]

def dfs(i):
    if i == 1:
        return [("a", 1)]
    else:
        ret = []
        for i in dfs(i-1):
            nowstr, nowmax = i
            for j in range(nowmax+1):
                ret.append((nowstr+alp[j], max(j+1,nowmax)))
        return ret

ans = dfs(n)
#print(ans)
for i in range(len(ans)):
    print(ans[i][0])
import sys
sys.setrecursionlimit(10 ** 9)
if __name__ == '__main__':
    def solve(s, a):
        if len(s) == n:
            print(s)
        else:
            for c in range(ord("a"), a + 1):
                if c == a:
                    solve(s + chr(c), a + 1)
                else:
                    solve(s + chr(c), a)
    n = int(input())
    solve("", ord("a"))
N=int(input())
def dfs(S):
    if len(S)==N:
        print(S)
    else:
        for i in range(97,ord(max(S))+2):
            dfs(S+chr(i))
dfs("a")
N = int(input())

alphabets = [chr(ord('a') + x) for x in range(26)]

ans = []


def dfs(d, i_max, S):
    if d == N-1:
        ans.append(S)
        return
    for i in range(i_max+2):
        dfs(d+1, max(i_max, i), S + alphabets[i])


dfs(0, 0, "a")
print(*ans, sep='\n')
n = int(input())

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

def dfs(s, cmax):
    if len(s) == n:
        print(s)
    else:
        for i in range(ord(cmax)-ord('a')+2):
            c = chr(i+ord('a'))
            if ord(c) < ord(cmax):
                dfs(s+c, cmax)
            else:
                dfs(s+c, c)

dfs('a', 'a')
N = int(input())
 
#from collections import deque
 
#Q = deque()
 
S = "a"
 
def printer(S,max_s):
    if len(S)==N:
        print(S)
    else:
        max_s = max(ord(S[-1])-ord('a'),max_s)
        for i in range(ord('a'),ord('a')+max_s+2):        
            printer(S + chr(i),max_s)
        
printer(S,0)
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    n -= 1
    now = ['a']
    for _ in range(n):
        next = []
        for S in now:
            d = ord(max(S)) - ord('a')
            for i in range(d+2):
                next.append(S + chr(i + ord('a')))
        now = next

    now.sort()
    for S in now:
        print(S)
resolve()
N = int(input())


def f(L):
    l = len(L)
    if l == N:
        print(''.join(list(map(lambda i: chr(i + 96), L))))
        return
    for d in range(1, min(l, max(L)) + 2):
        f(L + [d])


f([1])
ch = ['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']

n = int(input())

import queue
q=queue.Queue()
l = 1
q.put(["a", 0])

while True:
  temp = q.get()
  l=len(temp[0])
  if l==n:
    break
    
  for i in range(temp[1]+2):
    ne = temp[0]+ch[i]
    nn = max(temp[1], i)
    q.put([ne, nn])

print(temp[0])
while not q.empty():
  print(q.get()[0])
N = int(input())

lst = []
m = 0
temp = [[0]]

while temp:
    p = temp.pop()
    if len(p)==N:
        lst.append(p)
    else:
        for i in range(max(p)+2):
            s = p[:]
            s.append(i)
            temp.append(s)

lst.sort()
abc = 'abcdefghij'
for l in lst:
    print(*[abc[i] for i in l], sep='')
n=int(input())
s="abcdefghijklmno"
end=[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
lim=0
res=[0]*n
for i in res:
  print(s[i],end="")
print("")

while res!=end[:n]:
  res[(n-1)]=res[(n-1)]+1
  for i in range(n-1):
    if res[n-i-1]>(max(res[:(n-i-1)])+1):
      res[n-i-1]=0
      res[n-i-2]=res[n-i-2]+1
  for i in res:
    print(s[i],end="")
  print("")
# input
D = int(input())

S = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")

# process
def f(x):
    if x == 0:
        return ["a"]

    else:
        t =  f(x - 1)
        r = []
        for s in t:
            num = len(set(list(s)))
            for i in range(num+1):
                r.append(s+S[i])
        return r

ans = f(D-1)

# output
print(" ".join(map(str, ans)))
n = int(input())
res = [['a'],[],[],[],[],[],[],[],[],[]]
cha = ['a','b','c','d','e','f','g','h','i','j']

for x in range(1,n):
  for y in res[x-1]:
    for c in range(10):
      if cha[c] not in y:
        for d in range(c+1):
          res[x].append(y+cha[d])
        break
  if x > n + 1:
    break

for ans in range(len(res[n-1])):
  print(res[n-1][ans])
n=int(input())
def f(s):
  return len(set([s[i] for i in range(len(s))]))
alphabet = [chr(i) for i in range(97, 97+26)]
for i in range(1,n+1):
  if i==1:
    iso=["a"]
  else:
    iso_new=[]
    for s in iso:
      for j in range(f(s)+1):
        iso_new.append(s+alphabet[j])
    iso = list(set(iso_new))

iso.sort()
for s in iso:
  print(s)
import sys
sys.setrecursionlimit(10 ** 7)
ans = []
def solve(x, n, s):
    if len(s) == n:
        ans.append(s)
        return
    for i in range(x+2):
        solve(max(x, i), n, s + chr(ord("a") + i))

def main():
    n = int(input())
    solve(0, n, "a")
    ans.sort()
    for s in ans:
        print(s)

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

al = 'abcdefghijk'


def next(digits, kind, cur):
    if digits == N:
        print(cur)
        return
    for i in range(kind+1):
        if i == kind:
            next(digits+1, kind+1, cur+al[i])
        else:
            next(digits+1, kind, cur+al[i])


next(1, 1, 'a')
n=int(input())
l=["a","b","c","d","e","f","g","h","i","j"]
a="a"
ans=["a"]
for i in range(1,n):
    tt=[]
    for j in ans:
        s=len(set(j))
        for k in range(s+1):
            tt.append(j+l[k])
    ans=tt
ans.sort()
for i in ans:
    print(i)
n = int(input())
words = ['a', 'b', 'c', 'd', 'e', 'f','g','h', 'i', 'j']
ans = [[] for _ in range(n)]
ans[0].append(["a", 1])
for i in range(n - 1):
    for ai in ans[i]:
        for j in range(ai[1]):
            ans[i + 1].append([ai[0] + words[j], ai[1]])
        ans[i + 1].append([ai[0] + words[ai[1]], ai[1] + 1])

for a in ans[n - 1]:
    print(a[0])
N = int(input())
alp = lambda c: chr(c+96)
def num(L,key):
    if len(L) == N:
        ans = [alp(a) for a in L]
        print(''.join(ans))
    else:
        for k in range(1,key+1):
            l = L + [k]
            num(l,key)
        l = L + [key+1]
        num(l, key+1)

init =[1]
num(init,1)
n=int(input())

def go(s):
   global n
   if len(s)==n:
       print(s)
       return
   l=max(s)
   for i in range(ord('a'),ord(l)+1):
       go(s+chr(i))
   if l < 'z':
       go(s + chr(ord(l) + 1))

go("a")
alp='abcdefghijklmnopqrstuvwxyz'

def f(N, s, x):
  if len(s)==N:
    print(s)
    return
  for i in range(x+2):
    f(N, s+alp[i], max(x, i))
    
f(int(input()), 'a', 0)
N = int(input())

alp = "abcdefghijklmnopqrstuvwxyz"

ans =  [ ["",0] ]


for i in range(N):

    nex = []

    for s,i in ans:

        for j in range(i+1):

            nex.append([s+alp[j] , max(i,j+1)])

    ans = nex
    #print (ans)

ans.sort()

for s,i in ans:
    print (s)
def gen_pattern(N, pre=""):
  for c in range(0x61, ord(max(pre or "\x60"))+2):
    pat = pre+chr(c)
    if len(pat) == N:
      yield pat
    else:
      yield from gen_pattern(N, pat)

for pattern in gen_pattern(int(input())):
  print(pattern)
def rec(w, x, n):
    if len(w) == n:
        return print(w)
    else:
        for i in range(x + 1):
            rec(w + chr(ord('a') + i), x + 1 if i == x else x, n)


n = int(input())
rec("", 0, n)
def dfs(S):
    if len(S) == N:
        ans.append(S)
    else:
        for c in range(max(S) + 2):
            dfs(S + [c])


N = int(input())
ans = []
dfs([0])
for li in ans:
    print("".join(chr(c + ord("a")) for c in li))
def solve():
    N = int(input())
    ans = ['a']
    for i in range(N - 1):
        newest_ans = []
        for a in ans:
            A = [ord(b) for b in a]
            for t in range(min(A), max(A) + 2):
                newest_ans.append(a + chr(t))
        ans = newest_ans
    for a in sorted(ans):
        print(a)


if __name__ == "__main__":
    solve()
n = int(input())
s = 'abcdefghij'

def ans(a, c):
    if len(a)==n-1:
        for i in range(c):
            print(a+s[i])
    else:
        for i in range(c):
            a+=s[i]
            if i==c-1:
                ans(a, c+1)
            else:
                ans(a,c)
            a=a[0:-1]

ans('', 1)
N = int(input())
X = [chr(ord('a') + i) for i in range(N)]
first_presence = {x: i for x, i in zip(X, list(range(N)))}

R = ['a']
for i in range(1, N):
    next_r = []
    for r in R:
        max_s = max(r)
        for x in X[:first_presence[max_s] + 2]:
            next_r.append(r + x)
    R = next_r

ans = R
ans.sort()
print(*ans, sep="\n")
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)
n = int(input())

s = ['' for i in range(n)]
def dfs(k, c):
    if k == n:
        print("".join(s))
        return
    for i in range(c):
        s[k] = chr(i+ord('a'))
        dfs(k+1, c)
    s[k] = chr(c+ord('a'))
    dfs(k+1, c+1)

dfs(0, 0)
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
from itertools import combinations
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
if n == 1:
    print('a')
    sys.exit()


def dfs(s):
    if len(s) == n:
        print(''.join([chr(s + ord('a')) for s in s]))
    else:
        for i in range(len(set(list(s))) + 1):
            dfs(s + [i])
dfs([])
from string import ascii_lowercase
N = int(input())
ans = ['a']
for i in range(1, N):
    ans2 = []
    for a in ans:
        for b in ascii_lowercase[:len(set(a)) + 1]:
            ans2 += [a + b]
    ans = ans2
print('\n'.join(ans))
N=int(input())
A=["a"]
S="abcdefghijklmn"
for i 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))
n = int(input())
res = [-1] * n
def do(a, b):
    #print("do",a,b)
    if a >= n:
        return
    res[a] = b
    if a == n - 1:
        print("".join(list(map(lambda x: chr(ord("a") - 1 + x), res))))
        return
    for i in range(1, max(res[0:a+1])+2):
        do(a + 1, i)
do(0, 1)
N = int(input())
alphabet_list = [chr(i) for i in range(97, 97 + N)]

import collections

previous_list = ["a"]
for i in range(1, N):
    out_list = []
    for a in previous_list:
        # print(len(collections.Counter(a)))
        for al in alphabet_list[:len(collections.Counter(a))+1]:
            # print(a + al)
            out_list.append(a+al)
    previous_list = out_list

for out in previous_list:
    print(out)
n = int(input())
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
    A = [ a + s for a in A for s in S[:len(set(a)) + 1]]
print('\n'.join(A))
N = int(input())
from collections import deque
import itertools
ans = deque()
l = []
r = deque()
for i in range(N):
  l.append(chr(97+i))
  r.append(l.copy())
  

p = [[[] for _ in range(N)] for _ in range(N)]
p[0][0].append('a')
for i in range(1,N):
  for j in r[i]:
    x = ord(j)-97
    for n,k in enumerate(p[i-1][max(0,x-1):],max(0,x-1)):
      for m in k:
        p[i][max(n,x)].append(m+j)


p = p[-1]
p = list(itertools.chain.from_iterable(p))
p.sort()
for q in p:
  print(q)
N = int(input())

lst = [['a']]
for i in range(N - 1):
    n = len(lst)
    tmp_lst = []
    tmp_append = tmp_lst.append
    for j in range(n):
        tmp = lst[j]
        count = len(set(tmp))
        for k in range(count + 1):
            tmp_append(tmp + [chr(k + 97)])
    lst = tmp_lst
lst.sort()

for tmp in lst:
    print (*tmp, sep = '')
n=int(input())
ans=[]
def rec(i,s):
    if i == n:
        print(s)
        return
    else:
        for j in range(len(set(s)) + 1):
            rec(i+1,s+chr(ord("a")+j))
rec(1,"a")
n = int(input())
v = 'abcdefghijk'

w = []
def dfs(s,t):
  if len(s) == n:
    w.append(s)
    return
  u = len(set(s))
  for i in range(u+1):
    dfs(s+v[i],u+1)

dfs('a',1)

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

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

dfs([], 0)
import string
n = int(input())
cs = string.ascii_lowercase
cm = {cs[i]:i for i in range(len(cs))}
t = 1
def rec(st):
    global t
    if (len(st) >= n):
        print(st)
        t += 1
        return 0
    k = max(cm[st[i]]+1 for i in range(len(st)))
    for c in cs[: k + 1]:
        rec(st+c)
    
    
rec('a')
import sys
sys.setrecursionlimit(10**9)

N = int(input())

def bfs(s, cnt, m):
	if cnt == N:
		print(s)
		return

	for i in range(97,ord(m)+2):
		if chr(i) > m:
			bfs(s+chr(i), cnt+1, chr(i))
		else:
			bfs(s+chr(i), cnt+1, m)

bfs('a',1,'a')
n = int(input())

def dfs(s, cn):
    if len(s) == n:
        print(s)
    else:
        for i in range(0, cn + 1):
            c = chr(ord('a') + i)
            if i == cn: dfs(s+c, cn+1)
            else: dfs(s+c, cn)

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

alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]

def bitcount(v):
    cnt = 0
    for i in range(n + 1):
        cnt += bool(v & (1 << i))
    return cnt

results = []
def f(i=0, s=""):
    if len(s) == n:
        results.append(s)
        return

    for j in range(i + 1):
        if i != j:
            f(i, s + alp[j])
    f(i + 1, s + alp[i])
f()
print(*results, sep="\n")
n = int(input())
ans = ['a']

for i in range(n-1):
    buf = []
    for j in ans:
        l = len(set(j))
        for c in range(l+1):
            buf.append(j+chr(ord('a')+c))
    ans = buf

for i in ans:
    print(i)
def solve():
    N = int(raw_input())
    ret = [('a', 'a')]
    for i in range (2, N+1):
        tmp = []
        for stri in ret:
            for j in range(ord('a'), ord(stri[1]) + 1):
                tmp.append((stri[0] + chr(j), stri[1]))
            tmp.append((stri[0] + chr(ord(stri[1]) + 1), chr(ord(stri[1]) + 1)))
        ret = tmp
    for stri in ret:
        print stri[0]

if __name__ == '__main__':
    solve()
N = int(input())
al = [chr(ord('a') + i) for i in range(26)]
li = ['a']
for i in range(1,N):
    k = []
    li = set(li)
    for s in li:
        count = len(set(list(s)))
        for m in range(count+1):
            nk = s+al[m]
            k.append(nk)
    li = k
n = len(li)
li.sort()
for i in range(n):
    print(li[i])
n = int(input())
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[i] = str(chr(c)).lower()


ans = []
def dfs(s, mx, ans):
  if len(s) == n:
    ans += [s]
    return 
  else:
    for i in range(mx+1):
      dfs(s+alpha_dict[i], max(i+1, mx), ans)

dfs("", 0, ans)
ans = sorted(ans)
for a in ans:
  print(a)
n = int(input())

ans_b = []
ans_n = ['a']

s = ['a','b','c','d','e','f','g','h','i','j']

for i in range(1,n):
    ans_b = ans_n.copy()
    ans_n = []
    for j in ans_b:
        plus = 1
        ans_n.append(j+'a')
        while( j.count(s[plus-1]) > 0):
            ans_n.append(j+ s[plus])
            plus += 1

ans = sorted(ans_n)

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

ans = []
def dfs(x):
    if len(x) == n:
        ans.append(x)
        return
    for i in range(0, max(x)+1):
        y = x.copy()
        y.append(i+1)
        dfs(y)
dfs([1])
#print(ans)

r = ['a','b','c','d','e','f','g','h','i','j']
for ai in ans:
    print(''.join(map(lambda x: str(r[x-1]), ai)))
chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
n = int(input())
seq = [97 for i in range(n)]
i = n - 1
print('a' * n)
while i > 0:
    if seq[i] <= max(seq[:i]):
        seq[i] += 1
        i = n - 1
        print(''.join(map(chr, seq)))
    else:
        seq[i] = 97
        i -= 1
N = int(input())

a_num = 97

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

dfs("a", N-1)
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, max(map(int, list(c)))+2):
            q.append((i, b + chr(96+i), c + str(i)))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)
N = int(input())

def main(l):
  tmp = []
  for a in l:
    n = a[1]
    for i in range(97, n+2):
      tmp.append([a[0]+chr(i), max(i, n)])
  return tmp
  
l = [['a', 97]]
for i in range(1, N):
  l = main(l)
for i in range(len(l)):
  print(l[i][0])
from collections import deque


def main():
    N = int(input())

    av = ord('a')

    def to_s(ary):
        ans = "".join(map(lambda v: chr(v + av), ary))
        return ans

    def search(i, v, ary):
        if i == N:
            print(to_s(ary))
            return

        for u in range(0, v + 2):
            ary[i] = u
            search(i + 1, max(u, v), ary)

    ary = [0] * N
    search(0, -1, ary)


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


def f(n, lst):
    if n == N:
        print(''.join(map(str, [chr(s + 97) for s in lst])))
    else:
        for i in range(max(lst) + 2):
            f(n + 1, lst + [i])


f(1, [0])
import string
lower = string.ascii_lowercase

n = int(input())

# if n == 1:
#     print('a')
#     exit()

ans = ['']

for i in range(n):
    new_list = []
    for word in ans:
        for new_char in lower:
            if new_char in word:
                new_list.append(word + new_char)
            else:
                new_list.append(word + new_char)
                break
    ans = new_list
#    print(new_list)

for word in ans:
    print(word)
# -*- coding: utf-8 -*-
a = int(input())

l = 1
cur_ret = [[0]]
while l < a:
    new_ret = []
    na = new_ret.append
    for i in cur_ret:
        k = max(i) + 2
        for j in range(k):
            na(i+[j])
    cur_ret = new_ret
    l+=1

def format(x):
    x = list(map(lambda x : chr(x+97),x))
    return "".join(x)

cur_ret = list(map(format,cur_ret))
cur_ret.sort()
for i in cur_ret:
    print(i)
d = ['a','b','c','d','e','f','g','h','i','j']

n = int(input())

result = []

def fig(s, mx):
    if len(s) == n:
        result.append(s)
        return
    
    for i in range(mx+1):
        if i == mx:
            mx += 1
        fig(s + d[i], mx)

fig('', 0)
result.sort()

for r in result:
    print(''.join(r))
N = int(input())
alpha=list('abcdefghijklmnopqrstuvwxyz')
res=['']
for i in range(N):
    tmp = []
    for j in res:
        for k in alpha[:len(set(list(j))) +1]:
            tmp.append(j+k)
    res = tmp

for i in res:
    print(i)
N, = list(map(int, input().split()))


def gen(path, maxOrd):
    if len(path) == N:
        print("".join(chr(ord("a") + x) for x in path))
    else:
        for x in range(maxOrd + 2):
            path.append(x)
            gen(path, max(maxOrd, x))
            path.pop()


gen([], -1)
s="abcdefghijklmnopqrstuvwxyz"
import sys
sys.setrecursionlimit(10**6)
def dfs(a,n,m):
    if len(a)==n:
        print(a)
        return
    for i in range(m):
        if i==m-1:
            dfs(a+s[i],n,m+1)
        else:
            dfs(a+s[i],n,m)
n=int(input())
dfs("",n,1)
n = int(input())
ls = []
alphabet = [chr(i) for i in range(97, 97+26)]
alphabet_dict = {}
for i, a in enumerate(alphabet):
    alphabet_dict[a] = i
def dfs(A):
    if len(A) == n:
        ls.append(A)
        return
    Max = 0
    for i in range(len(A)):
        Max = max(Max,alphabet_dict[A[i]])
    for i in range(Max+2):
        A += alphabet[i]
        dfs(A)
        A = A[:-1]
dfs('a')
ls.sort()
for i in range(len(ls)):
    print(ls[i])
import collections
alpha=['a','b','c','d','e','f','g','h','i','j']
def a(n):
  if n==1:
    return ['a']
  else:
    box=[]
    alphan=alpha[:n+1]
    for i in a(n-1):
      kind=collections.Counter(i)
      for j in range(len(kind)+1):
        box.append(i+alpha[j])
  return box
for i in a(int(input())):
  print(i)
n = int(input())
a = ord('a')

def dfs(s, m):
    # print("dfs", s, chr(m))
    if len(s) == n:
        print(s)
    else:
        for i in range(m + 1 - a):
            dfs(s + chr(a + i), m + 1 if i == m - a else m)

dfs("", a)
n = int(input())
l = ['a','b','c','d','e','f','g','h','i','j']

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

dfs('',0)
import itertools
import sys

n = int(input())
S = [0]*n
while True:
    print("".join(map(lambda x:chr(ord('a')+x),S)))
    for i in range(n-1,0,-1):
        if(i>0 and max(S[:i])>=S[i]):
            S[i] += 1
            for j in range(i+1,n):
                S[j] = 0
            break
    else:
        break
n=int(input())
def d(s):
  if len(s)==n:print(s)
  else:
    for i in range(97,ord(max(s))+2):d(s+chr(i))
d("a")
N = int(input())
alpha = [chr(ord("a") + i) for i in range(26)]


def dfs(n, s):
    if len(s) == n:
        print(s)
        return
    cnt = len(set(s))
    cnt += 1

    for a in alpha[:cnt]:
        ns = s + a
        dfs(n, ns)


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

def f(s):
    if len(s) == N:
        print(s)
        return
    for i in range(97, ord(max(list(s)))+1+1):
        ns = s + chr(i)
        f(ns)

f('a')
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d


def main():
    n = int(input())
    data = [chr(ord("a") + i) for i in range(10)]
    generate("a", 0, n, data)


def generate(cur, max_i, n, data):
    if len(cur) == n:
        print(cur)
        return
    for i in range(max_i + 2):
        generate(cur + chr(ord("a") + i), max(max_i, i), n, data)


if __name__ == '__main__':
    main()
def main():
    from collections import Counter as ct
    n = int(input())
    word_list = [""]
    for i in range(n):
        word_list2 = []
        for i in word_list:
            c = len(ct(i))
            for j in range(c+1):
                word_list2.append(i+"abcdefghij"[j])
        word_list = word_list2
    word_list.sort()
    for i in word_list:
        print(i)


main()
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


s = 'abcdefghijklmnop'
N = I()


def f(n, seq, m):
    for i in range(m + 1):
        if n == N:
            print(seq + s[i])
        else:
            f(n + 1, seq + s[i], max(m, i + 1))


f(1, '', 0)