peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
sys.setrecursionlimit(100000)

strings=["a","b","c","d","e","f","g","h","i","j"]

N=int(input())
def f(x):
    for i in x:
        print(strings[i],end="")
    if x[-1]==N-1:
        return ""
    print("")
    if x[-1]-1==x[-2]:
        x[-1]+=1
        return f(g(x,N-1))
    else:
        x[-1]+=1
        return f(x)
import string

def dfs(w):
    if len(w) == N:
        print(w)
        return
    for i in range(N):
        dfs(w + string.ascii_lowercase[i])

N = int(input())
anslst = []
nlst = [0] * N
wordlst = string.ascii_lowercase
dfs('a')
n = int(input())
if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n == 3:
    print("aaa")
    print("aab")
    print("aba")
    print("abb")
    print("abc")
N=input()
A="abcdefghij"

S=["a"]
for n in range(2,N+1):
    temp=[]
    for s in S:
        for i in range(n):
            if i==n-1:
                if s[-1]==A[i-1]:
                    temp.append(s+A[i])
            else:
                temp.append(s+A[i])
    S=temp

S.sort()
for x in S:
    print x
alpha_small_ = [chr(i) for i in range(97, 97+26)] #アルファベッドの小文字

n = int(input())
ans = []
def solve(now,i):
    if len(now) == n:
        ans.append(now)
        return
    for j in range(i+1):
        solve(now+alpha_small_[j],j+1)

solve("a",1)


for x in sorted(ans):
    print(x)
import sys
n = int(input())
ans = ""
if n == 1:
    print("a")
    sys.exit(0)
else:
    c = 2 ** (n-1)
    for i in range(c):
        tmp = "a"
        for j in range(n-1):
            if i >> j & 1:
                tmp += "b"
            else:
                tmp += "a"
        print(tmp)
n = int(input())
candidate = ['a']


def dfs(s, c):
    if len(s) == n:
        return
    candidate.append(s + c)
    candidate.append(s + chr(ord(c) + 1))
    dfs(s + c, c)
    dfs(s + chr(ord(c) + 1), chr(ord(c) + 1))


dfs('a', 'a')

for c in candidate:
    if len(c) == n:
        print(c)
n = int(input())
cands = set([])

def dfs(count,i):
  if count ==0:
    cands.add(tuple(i))
  for j in range(1,count+1):
    dfs(count-j,i+[j])
dfs(n,[])

from itertools import permutations

ans = []
for c in cands:
  s = ''
  for i in range(len(c)):
    s += chr(97+i)* c[i]
    ans.extend(list(permutations(s,n)))
ans = list(set(ans))
ans.sort()
for i in range(len(ans)):
  for j in range(n):
    if ord(ans[i][j])-97 > j:
      break
  else:
    print(''.join(ans[i]))
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
C=[1]*n
Ans=[C]
cur=n-1
while cur:
  cur=0
  for i in range(n-1):
    if C[i+1]<i+2:
      cur=i+1
  D=[]
  for i in range(n):
    if i<cur:
      D.append(C[i])
    elif i==cur:
      D.append(C[i]+1)
    else:
      D.append(1) 
  if cur!=0:
    Ans.append(D)
  C=Ans[-1]
for a in Ans:
  ans=""
  for i in range(n):
    ans+=chr(a[i]+96)
  print(ans)
import itertools
n = int(input())
l = [i for i in range(1, n+1)]
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[i+1] = chr(c)

ans = set()
for v in itertools.combinations_with_replacement(l, n):
  m = min(v)
  diff = m - 1 
  tmp = ""
  for n in v:
    tmp += str(alpha_dict[n-diff].lower()) 
  ans.add(tmp)

ans = sorted(list(ans))
for v in ans:
  print(v)
n = int(input())
data = ["a"] * n
ans = ["".join(data)]
def print_str(ans, data, i):
    if i == n:
        return
    while ord(data[i]) + 1 <= ord(data[i - 1]) + 1:
        data[i] = chr(ord(data[i]) + 1)
        ans.append("".join(data))
        print_str(ans, data, i + 1)
    data = ["a"] * n
    print_str(ans, data, i + 1)
print_str(ans, data, 1)
ans = sorted(set(ans))
for i in range(len(ans)):
    print(ans[i])
N = int(input())

words = [chr(ord('a')+i) for i in range(10)]
dp = ['']
for i in range(1, N+1):
    ndp = []
    for w in dp:
        for k in range(i):
            ndp.append(w+words[k])
    dp = ndp
for l in dp:
    print(l)
import math
import queue

n = int(input())

q = queue.Queue()
q.put("a")

while True:
    c = q.get()
    if len(c) > n:
        break
    if len(c) == n:
        print(c)

    nx = c[-1]
    if nx != "a":
        q.put(c + chr(ord(nx) - 1))
    q.put(c + nx)
    q.put(c + chr(ord(nx) + 1))
n = int(input())
data = ["a"] * n
ans = ["".join(data)]
def print_str(ans, data, i):
    if i == n:
        return
    while ord(data[i]) + 1 <= ord(data[i - 1]) + 1:
        data[i] = chr(ord(data[i]) + 1)
        ans.append("".join(data))
        print_str(ans, data, i + 1)

print_str(ans, data, 1)
ans = sorted(set(ans))
for i in range(len(ans)):
    print(ans[i])
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(a[-1])+2):
                ANS[i].append(a+chr(j))
print(*ANS[N],sep='\n')
from collections import deque
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j","k"]
ansl = []
d = deque()
ans = "a"
d.append([ans,0])
while len(d):
    now,m = d.pop()
    if len(now) == n:
        ansl.append(now)
    else:
        for i in range(m+2):
            d.append([now+l[i],i])
ansl.sort()
for i in ansl:
    print(i)
import sys
import math

def permutations_count(n, r):
  ret = 0
  for i in range(r):
    ret += (n-i)
  return ret
  
N = int(input())
#print(N)
if N == 1:
  print(1)
  sys.exit()
elif N == 2:
  print(2)
  sys.exit()

r = N - 2

ret = permutations_count(N, r) + 2
print(ret)
N = int(input())

que = ['a']
res = []
for i in range(1, N):
    for q in que:
        res.append(q + 'a')
        res.append(q + 'b')
    que = res
    res = []
    
for q in que:
    print(q)
n = int(input())

alpha = "abcdefghijklmnopqrstuvwxyz"

inp = [""]
for i in range(n):  # ふかさのループ
    out = []
    for j in range(len(inp)):  # リストのループ
        for k in range(i):  # アルファベットのループ
            out.append(inp[j] + alpha[k])
    out.append(inp[j] + alpha[i])
    inp, out = out, inp

for i in range(len(inp)):
    print(inp[i])
n = int(input())
q = ["0"]
cnt = 0
while cnt < n - 1:
    qt = []
    for num in q:
        lastnum = num[-1]
        for i in range(int(lastnum) + 2):
            qt += [num + str(i)]
    q = qt.copy()
    cnt += 1
    
alp = "abcdefghijkl"
    
def show(num):
    ret = ""
    l = len(num)
    for i in range(l):
        ret += alp[int(num[i])]
    return ret

q.sort()

for num in q:
    print(show(num))
n = int(input())
s = "bcdefghijk"
if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n == 5:
    print("aaaab")
    print("aaaac")
    print("aaaad")
    print("aaaae")
    print("aaaaf")
N = int(input())

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

ans = []

def dfs(s):
    if len(s) == N:
        # print(s)
        ans.append(s)
        return
    
    end = s[-1]
    end_i = chars.index(end)
    for i in range(end_i + 2):
        ns = s + chars[i]
        # print('-', i, ns)
        dfs(ns)

dfs('a')


ans.sort()
for si in ans:
    print(si)
n=int(input())
s="abcdefghij"
end=[0,1,2,3,4,5,6,7,8,9]
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]>(res[n-i-2]+1):
      res[n-i-1]=0
      res[n-i-2]=res[n-i-2]+1
  for i in res:
    print(s[i],end="")
  print("")
if __name__ == '__main__':
    n = int(input())
    r = lambda n: [''] if n <= 0 else [e + j for e in r(n - 1) for j in [chr(ord('a') + e) for e in range(n)]]
    a = r(n)
    for e in a:
        print(e)
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), i+1)

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

for i in range(n):
  s = ''
  for j in range(i+1):
    s += p[j]
  if n % len(s) == 0:
    a = s*(n//len(s))
    print(a)
  else:
    b = n % len(s)
    #print(b)
    a = s*(n//len(s)) + s[:b]
    print(a)
N=int(input())
alp="abcdefghij"
S=[""for i in range(N)]

def gen(cnt,rem):
    if rem==0:
        print("".join(S))
    else:
        for i in range(min(N,cnt+2)):
            S[N-rem]=alp[i]
            gen(i,rem-1)            

S[0]="a"
gen(0,N-1)
def dfs(s):
    if len(s)>n:
        return
    t.append(s)
    for c in 'abcdefghij':
        if ord(c)-ord(s[-1])<=1:
            dfs(s+c)

n=int(input())
if n==1:
    print('a')
    exit(0)
t=[]
ans=[]
dfs('a')

for tt in t:
    if len(tt)==n:
        ans.append(tt)
ans.sort()
print(*ans,sep='\n')
n=int(input())
s=''
t=ord('a')
#print(t)
for i in range(n):
 s+=chr(t+i)
 print(s)
n = int(input())

def aa(nokori, str, nowID, firstID):
  if nokori == 1:
    print(str+chr(nowID))
    return
  for i in range(nowID - firstID + 2):
    aa(nokori-1, str+chr(nowID), firstID + i, firstID)
 
aa(n, "", 97, 97)
N = int(input())


def solve(N):
    if N == 1:
        return ["a"]
    result = []
    for s in solve(N-1):
        result.append(s+'a')
        result.append(s+'b')
    return result

for s in sorted(solve(N)):
    print(s)
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[:i + 1]:
            ans2 += [a + b]
    ans = ans2
print('\n'.join(ans))
N = int(input())
# alpha = [chr(ord("a")+i) for i in range(10)]
ans = [[] for _ in range(N)]
ans[0].append("a")
for i in range(N-1):
    for e in ans[i]:
        idx = ord(e[-1]) - ord("a")
        for j in range(idx+2):
            ans[i+1].append(e+chr(ord("a")+j))
for i in range(len(ans[N-1])):
    print(ans[N-1][i])
N = int(input())

alphabets = 'abcdefghijklmnopqrstuvwxyz'

def dfs(s, max_idx):
  if len(s) == N:
    print(s)
    return
  else:
    for i in range(0, max_idx+1):
      t = s
      t = t + alphabets[i]
      dfs(t, max(i, max_idx)+1)
    
dfs("", 0)
n=int(input())
def dfs(s,st):
  if len(s)==n:
    return print(s)
  else:
    for i in range(ord('a'),ord(st)+1):
      dfs(s+chr(i),chr(i+1))
dfs('','a')
import itertools

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

    init = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']
    print(''.join(init[0:n]))
    for str in itertools.combinations_with_replacement(l[0:n], n):
        if len(list(set(str))) != 1:
            print(''.join(str))
            
resolve()
n = int(input())

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

results = []
def f(i=0, j=0, s="a"):
    if i == n - 1:
        return results.append(s)
    f(i + 1, j, s + alp[j])
    f(i + 1, j + 1, s + alp[j + 1])
f()
print(len(results))
print(*results, sep="\n")
import itertools

n = int(input())

cl = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ]
rl = itertools.product(cl[:n], repeat=n - 1)
if not rl:
    print("a")
else:
    for r in rl:
        print("".join(["a"] + list(r)))
import sys
sys.setrecursionlimit(10**9)

ordA = ord('a')

N = int(input())

def dfs(i, sSt):
    if i == N:
#        print(Ss)
        ans = ''.join([chr(ordA+S) for S in Ss])
        anss.append(ans)
    else:
        for s in range(0, sSt+2):
            Ss[i] = s
            dfs(i+1, s)

anss = []
Ss = [0] * N
dfs(1, 0)

print('\n'.join(anss))
n = int(input())

if n==1:
  print("a")
elif n==2:
  print("aa")
  print("ab")
elif n==3:
  print("aaa")
  print("aab")
  print("abb")
  print("aba")
  print("abc")
elif n==4:
  print("aaaa")
  print("aaab")
  print("aaba")
  print("abaa")
  print("aabb")
  print("abba")
  print("abab")
  print("abbb")
  print("aabc")
  print("abac")
  print("abca")
  print("abbc")
  print("abcb")
  print("acbc")
  print("abcc")
  print("abcd")
else:
  print("")
import sys
sys.setrecursionlimit(10 ** 7)
ans = []
def solve(pre, n, s):
    if len(s) == n:
        ans.append(s)
        return
    for i in range(pre+2):
        solve(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()
import string
ans = []
N = int(input())

def rec(s, i):
    if len(s) == N:
        ans.append(s)
        return
    for c in string.ascii_lowercase[:i+1]:
        rec(s + c, i + 1)

rec("a", 1)
ans.sort()
for x in ans:
    print(x)
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    N = int(input())
    q = deque(["a"])
    cnt = 1
    while cnt <= N:
        d = q.popleft()

        if len(d) == N:
            print(d)
        cnt = max(cnt, len(d))
        a = ord(d[-1])
        for i in range(ord("a"), a + 2):
            q.append(d + chr(i))


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

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


def dfs(ans, keep_num, n):
    if n == N - 1:
        for i in range(keep_num + 2):
            print(ans + lis[i])
    else:
        for i in range(n + 1):
            dfs(ans + lis[i], max(i, keep_num), n + 1)


dfs('', 0, 0)
from itertools import permutations

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

for p in permutations(range(N)):
    D = [-1] * N
    A = []
    for i in range(N):
        for j in range(N):
            if D[j] < p[i]:
                D[j] = p[i]
                A.append(j)
                break
    ans.append(A)

ans.sort()

for a in ans:
    s = ''.join(map(lambda x:chr(x+97),a))
    print(s)
from string import ascii_lowercase
from itertools import product
n = int(input())
alphabets = ascii_lowercase[:n]

def check(s):
    if s[0] == 'a':
        now = 'a'
        for i in range(1, n):
            if s[i] == chr(ord(now)+1) or s[i] == chr(ord(now)) or s[i] == 'a':
                now = s[i]
            else:
                return False
        return True
    return False

for s in product(alphabets, repeat=n):
    if check(s):
        print(*s, sep='')
import copy
n = int(input())

def dfs(str_list, now):
    str_list.append(chr(now))
    if len(str_list) == n:
        print(''.join(str_list))
    else:
        chr_a = ord('a')
        for c in range(chr_a, now + 2, 1):
            str_list_cp = copy.deepcopy(str_list)
            dfs(str_list_cp, c)

dfs([], ord('a'))
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        print(s)
        return True
    # for ns in 'abcdefghijklmnopqrstuvwxyz'[:n+1]:
    for i, ns in enumerate('abcdefghij'[:n+1]):
        dfs(s+ns, max(i, n+1))

dfs('', 0)
import itertools as iters

N = int(input())
alpha = "abcdefghijk"
for s in iters.product(range(1,N+1),repeat=N-1):
    #print(s)
    r = [alpha[ss-1] for ss in s]
    print("a"+"".join(r))
n = int(input())
data = ["a"] * n
ans = ["".join(data)]
def print_str(ans, data, i):
    if i == n:
        return
    data[i] = "a"
    ans.append("".join(data))
    while ord(data[i]) + 1 <= ord(data[i - 1]) + 1:
        data[i] = chr(ord(data[i]) + 1)
        ans.append("".join(data))
        print_str(ans, data, i + 1)
    data = ["a"] * n
    print_str(ans, data, i + 1)
print_str(ans, data, 1)
ans = sorted(set(ans))
for i in range(len(ans)):
    print(ans[i])
import itertools

n = int(input())

cl = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ]
rl = itertools.product(cl[:2], repeat=n - 1)
if not rl:
    print("a")
else:
    for r in rl:
        print("".join(["a"] + list(r)))
N = int(input())

A = [0] * N

ED = [chr(i + 97) for i in range(N)]
ED = ''.join(ED)
ans = []
while True:
    for i in range(N - 1, 0, -1):
        if A[i] == A[i - 1] + 2:
            A[i] = 0
            A[i - 1] += 1
    ret = ['' for _ in range(N)]
    for i in range(N):
        ret[i] = chr(A[i] + 97)

    ret = ''.join(ret)
    ans.append(ret)

    if ret == ED: break
    else: A[-1] += 1

print(*sorted(ans),sep='\n')
n = int(input())

def aa(str):
  if len(str) == n:
    print(str)
    return
  for i in range(ord("a"), ord(str[-1])+2):
    aa(str+chr(i))

aa("a")
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  def dfs(s, depth=1):
    if depth == n:
      print(s)
      return
    for i in range(ord(s[-1]), ord('a')+n):
      dfs(s + chr(i), depth+1)
  dfs('a')
      
if __name__=='__main__':
  main()
import numpy as np
N = int(input())
s_lis = ["a"]
s_list = np.array(s_lis)
for i in range(N-1):
    ss = np.array([])
    for s in s_list:
        ss = np.append(ss,s + (s[-1]))
        ss = np.append(ss,s + chr(ord(s[-1])+1))
    s_list = np.copy(ss)
if N == 1 :
    print (s_lis[0])
else :
    for i in ss:
        print(i)
N = int(input())

ans = []
chars = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
def func(N, s):
    if len(s) == N:
        ans.append(s)
        return

    if len(s) == 0:
        size = 1
    else:
        size = ord(s[-1]) - 95
    for c in chars[:size]:
        func(N, s+c)

func(N,"")

ans.sort()
for i in range(len(ans)):
    print(ans[i])
from collections import deque
n=int(input())

alpha=list('abcdefghijk')

q=deque([])
q.append(alpha[0])

for i in range(1,n):
    qi=deque([])

    while(len(q)>0):
        qij=q.popleft()
        for j in range(len(qij)+1):
            qi.append(qij+alpha[j])

    q=qi

q=list(q)
q.sort()
for i in range(len(q)):
    print(q[i])
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**5)
to = "abcdefghij"


def dfs(s, p):
    if len(s) == n:
        print(s)
        return
    if p - 1 >= 0:
        dfs(s + to[p - 1], p - 1)
    if p >= 0:
        dfs(s + to[p], p)
    dfs(s + to[p + 1], p + 1)
    if len(s) > 0:
        m = max(ord(c) - ord("a") for c in s) + 1
        if p + 1 != m:
            dfs(s + to[m], m)


n = int(input())
dfs("", -1)
n = int(input())
s = "bcdefghijk"
if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n == 3:
    print("aaa")
    print("aab")
    print("aba")
    print("abb")
    print("abc")
N = int(input())
alp = ["b","c","d","e","f","g","h","i","j","a"]
a = "a"
A = "a"
for i in range(N):
    word = [a]
    word = [A]
    a = a + "a"
    A = A + alp.pop(0)
word.pop(0)
s = "\n".join(word)
print(s)
from itertools import product, combinations_with_replacement
N=int(input())
s="abcdefghij"
for i in range(N):
  c = s[:i+1]
  for p in product(s[:i+2],repeat=N-i-1):
    if p and p[0] not in c:
      break
    print(c+"".join(p))
def permutationWithRepetitionListRecursive(data, r):
    if r <= 0:
        return []

    result = []
    _permutationWithRepetitionListRecursive(data, r, [], result)
    return result

def _permutationWithRepetitionListRecursive(data, r, progress, result):
    if r == 0:
        result.append(progress)
        return
    for i in range(len(data)):
        _permutationWithRepetitionListRecursive(data, r - 1, progress + [data[i]], result)
    

n =int(input())
alp = [chr(i+96) for i in range(1,n+1)]

pros = permutationWithRepetitionListRecursive(alp,n)
for pro in pros:
    print(''.join(pro))
al = "abcdefghijklmnopqrstuvwxyz"
def dfs(s: "char", max_char: "int", n: "int", k):
    if(n<k):
        dfs(s+al[max_char], max_char, n+1, k)
        dfs(s+al[max_char+1], max_char+1, n+1, k)


    if n==k:
        print(s)



def main():
    k = int(input())
    #文字を選ぶ選ばないdfs
    dfs("a", 0, 1, k)


if __name__ == '__main__':
    main()
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]
            ans(a, i+2)
            a=a[0:-1]

ans('', 1)
N = int(input())

lst = []


def dfs(s, n):
    lst.append(s)
    if n == N:
        return
    else:
        return dfs(s + 'a', n + 1), dfs(s + 'b', n + 1)


dfs('a', 1)
for i in range(len(lst)):
    if len(lst[i]) == N:
        print(lst[i])
from itertools import combinations_with_replacement

N = int(input())
C = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Ans = set()

for ans in combinations_with_replacement(C[:N], N):
    a = ''
    d = dict()
    now = ord('a')
    for c in ans:
        if c not in d:
            d[c] = chr(now)
            now += 1
        a += d[c]
    Ans.add(a)

A = []
for ax in Ans:
    A.append(ax)
A.sort()
for a in A:
    print(a)
N = int(input())
alp = ["a","b","c","d","e","f","g","h","i","j"]
a = "a"
A = "a"
for i in range(N):
    word = [a]
    word = [A]
    a = a + "a"
    A = A + alp.pop(0)
word.pop(0)
s = "\n".join(word)
print(s)
def main():
    n = int(input())

    ans = []

    def fanc(i, l, s):
        if l == n:
            ans.append(s)
        else:
            for x in range(i+1):
                fanc(x + 1, l + 1, s + chr(97 + x))

    fanc(0, 0, "")

    ans.sort()

    for i in ans:
        print(i)

main()
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
#ans = []
def bfs(s):
    if len(s)==n:
        print(s)
        #ans.append(s)
        return
    for i in range(ord('a'),ord(s[-1])+2):
        bfs(s+chr(i))
bfs('a')
#bfs('a')
#print(*ans,sep='\n')
N = int(input())

alp = "abcdefghijklmnopqrstuvwxyz"

def dfs(s):
    i = len(s)
    if i == N:
        print(s)
    else:
        index = alp.index(s[-1])
        for i in range(index+2):
            dfs(s+alp[i])

dfs("a")
# coding: utf-8
n = int(input())

alphas = "abcdefghij"
init_str = ""

def standard(moji, x):
    if len(moji) == n:
        print(moji)
    else:
        for j in range(x):
            if j == x:
                standard(moji + alphas[j], i + 1)
            else:
                standard(moji + alphas[j], i)


standard(init_str, 0)
numal=lambda c:chr(c+97)
n=int(input())
alp="abcdefghij"
unchi=[[],[],[],[],[],[],[],[],[],[]]
unchi[0].append("0")
k=1
if n>=2:
	while k<n:
		for i in range(len(unchi[k-1])):
			unchi[k].append(unchi[k-1][i]+str(int(unchi[k-1][i][k-1])))
			unchi[k].append(unchi[k-1][i]+str(int(unchi[k-1][i][k-1])+1))
		k+=1
for i in range(len(unchi[n-1])):
	s = []
	for k in range(n):
		s.append(numal(int(unchi[n-1][i][k])))
	print("".join(s))
from itertools import product
N = int(input())

c = [chr(97 + i) for i in range(N)]

ans = []
for i in range(1, N):
    S = c[:i]
    tmp = [1] * i
    add = N - i
    for p in product(range(N - i + 1), repeat=i):
        if sum(p) == add:
            letter = ""
            for j in range(i):
                letter += S[j] * (tmp[j] + p[j])
            ans.append(letter)
ans.append("".join(c[:N]))

print(*ans, sep="\n")
n = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
a = []
def h(i, s, t):
	if i == 0:
		a.append(s)
		print(s)
	else:
		for j in range(t+1):
			ns = s+l[j]
			h(i-1, ns, t+1)
h(n, "", 0)
n = int(input())
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
    A = [ a + s for a in A for s in S[:len(a) + 1]]
print('\n'.join(A))
def solve(ans, p, n):
    if len(p) == n:
        s = ""
        for v in p:
            s += chr(ord("a")+v)
        ans.append(s)
        return
    for v in range(p[-1]+2):
        p.append(v)
        solve(ans, p, n)
        p.pop()
    return

def main():
    n = int(input())
    ans = []
    p = [0]
    solve(ans, p, n)
    ans.sort()
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()
import itertools
n =int(input())
alp = [chr(i+96) for i in range(1,n+1)]
cmbs = list(itertools.combinations_with_replacement(alp,n))
for cmb in cmbs:
    flg = False
    for i, al in enumerate(alp):
        if al in cmb:
            for a in alp[0:i]:
                if a not in cmb:
                    flg = True
                    break
            if flg:
                break
    if not flg:
        print(''.join(cmb))
import numpy as np
N = int(input())
s_lis = ["a"]
s_list = np.array(s_lis)
for i in range(N-1):
    ss = np.array([])
    for s in s_list:
        ss = np.append(ss,s + (s[-1]))
        ss = np.append(ss,s + chr(ord(s[-1])+1))
        if ord(s[-1]) > ord('a'):
            ss = np.append(ss,s + chr(ord(s[-1])-1))
    s_list = np.copy(ss)
if N == 1 :
    print (s_lis[0])
else :
    for i in ss:
        print(i)
import string
ans = []
N = int(input())

def rec(s, i):
    if len(s) == N:
        ans.append(s)
        return
    # tmp = set()
    for c in string.ascii_lowercase[:i + 1]:
        # if len(set(s + c)) in tmp:
        #     continue
        # tmp.add(len(set(s + c)))
        rec(s + c, i + 1)

rec("a", 1)
ans.sort()
for x in ans:
    print(x)