CodeEff/ECCO huggingface dataset:
# Original solution
N,Q = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(Q):
    m = -1
    spam = int(eval(input()))
    for n in C:
        ham =n%spam 
        m =  max(m,ham) 
    print(m)

# Optimized solution
def next_max(lst,mi,v):
    l, r = 0, mi-1
    while l <= r:
        mid = int((l+r)/2)
        if lst[mid] == v: return mid -1
        if lst[mid] > v:
            r = mid - 1
        else:
            l = mid + 1
    return r


N,Q = list(map(int,input().split()))
C = list(map(int,input().split()))
C.sort()
for i in range(Q):
    t = int(eval(input()))
    idx = N-1
    m = C[-1]% t
    idx = next_max(C,idx,C[idx]-m)
    while idx >= 0:
        amr = C[idx]%t
        m = max(m,amr) 
        idx = next_max(C,idx,C[idx]-amr)
    print(m)
# Original solution
N,Q = list(map(int,input().split()))
C = list(map(int,input().split()))

M = max(C)+1
t1 = [0]*(M)
for v in C:
    t1[v] = 1

t2 = [0]*(M)
v = 0
for i in range(M):
    if t1[i]:
        v = i
    t2[i] = v

for i in range(Q):
    t = int(eval(input()))
    n_v = M-1
    m = 0
    while n_v != 0:
        amr = n_v % t
        m = max(m,amr) 
        n_v = t2[n_v-1]

    print(m)

# Optimized solution
N,Q = list(map(int,input().split()))
C = list(map(int,input().split()))

M = max(C)+1
t1 = [0]*(M)
for v in C:
    t1[v] = 1

t2 = [0]*(M)
v = 0
for i in range(M):
    if t1[i]:
        v = i
    t2[i] = v

for i in range(Q):
    t = int(eval(input()))
    n_v = M-1
    m = 0
    while n_v != 0:
        amr = n_v % t
        m = max(m, amr) 
        tmp = n_v-m-1
        if tmp <= 0: break
        n_v = t2[tmp]

    print(m)
# Original solution
# Aizu Problem 0270: Modular Query

import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N, Q = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
for q in range(Q):
    m = int(eval(input()))
    print((max([a % m for a in A])))

# Optimized solution
N,Q=list(map(int,input().split()))
c=list(map(int,input().split()))
 
mxc=max(c)
p=[0]*(mxc+1)
for i in c:
    p[i]=1
     
l=[0]*(mxc+1)
num=0
for i in range(mxc+1):
    l[i]=num
    if p[i]:
        num=i
         
for i in range(Q):
    q=int(input())
    sp=mxc
    ans=0
    while 1:
        r=sp%q
        ans=max(ans,r)
        if sp-r<=0:break
        sp=l[sp-r]
    print(ans)
# Original solution
import sys

lst = []
for line in sys.stdin:
    num = line.strip()
    if num == "0":
        print(lst.pop())
    else:
        lst.append(num)

# Optimized solution
import sys

lst = []
for line in sys.stdin:
    if line.strip() :
        num = int(line.strip())
        if num == 0:
            print(lst.pop())
        else:
            lst.append(num)
# Original solution
import sys

file_input = sys.stdin

NM = file_input.readline()

import itertools

while NM != '0 0\n':
    N, M = list(map(int, NM.split()))
    P = [int(file_input.readline()) for i in range(N)]
    P.append(0)
    P = list(set(P))
    P.sort()
    scores = list(map(sum, itertools.combinations_with_replacement(P, 4)))
    print((max([x for x in scores if x <= M])))
    NM = file_input.readline()

# Optimized solution
import sys

file_input = sys.stdin

NM = file_input.readline()

import itertools, bisect

while NM != '0 0\n':
    N, M = list(map(int, NM.split()))
    P = [int(file_input.readline()) for i in range(N)]
    P.append(0)
    scores = list(map(sum, itertools.combinations_with_replacement(P, 2)))
    scores = list(set(scores))
    scores.sort()
    ans = []
    for s1 in scores:
        rest = M - s1
        i = bisect.bisect_right(scores, rest)
        if i:
            ans.append(s1 + scores[i - 1])
    print((max(ans)))
    NM = file_input.readline()
# Original solution
import bisect
while 1:
    n,m=list(map(int,input().split()))
    if n==0:break
    s,a=[],[0]*(n+1)
    for i in range(1,n+1):
        a[i]=int(eval(input()))
        for j in range(i+1):
            if a[i]+a[j]<=m:s+=[a[i]+a[j]]
            else:break
    s.sort()
    print((max(i+s[bisect.bisect_right(s,m-i)-1]for i in s)))

# Optimized solution
import bisect
while 1:
    n,m=list(map(int,input().split()))
    if n==0:break
    s=[]
    a=[0]+sorted([int(eval(input())) for _ in range(n)])
    for i in range(n+1):
        for j in a[i:]:
            if a[i]+j>m:break
            s+=[a[i]+j]
    s.sort()
    print((max(i+s[bisect.bisect_right(s,m-i)-1]for i in s)))
# Original solution
import bisect
while True:
    N,M=list(map(int,input().split()))
    if N==M==0:break
    L=[eval(input()) for i in range(N)]
    L.append(0)
    S=set(i+j for i in L for j in L)
    B=sorted(S)
    maxInt=0
    for i in B:
        if i>M:break
        idx=bisect.bisect(B,M-i)
        if i+B[idx-1]<=M:
            maxInt=max(maxInt,i+B[idx-1])
    print(maxInt)

# Optimized solution
import bisect
while True:
    N,M=list(map(int,input().split()))
    if N==M==0:break
    L=[eval(input()) for i in range(N)]
    L.append(0)
    S=set(i+j for i in L for j in L)
    B=sorted(S)
    maxInt=0
    for i in B:
        if i>M:break
        idx=bisect.bisect(B,M-i)
        maxInt=max(maxInt,i+B[idx-1])
    print(maxInt)
# Original solution
while(1):
    [N,M]=[int(x) for x in input().split()]
    if N==0:
        break
    a=[0]
    for i in range(N):
        a.append(int(input()))
    #b=sorted([x+y for x in a for y in a])
    #c=[]
    #for i in range(1,len(b)):
    #    if b[i]>M:
    #        break
    #    elif b[i-1]!=b[i]:
    #        c.append(b[i-1])
    b=[a[x]+a[y] for x in range(N+1) for y in range(x,N+1)]
    #c=f7(b)
    c=sorted(b)
    largest=0
    id=0
    for i in range(1,len(c)+1):
        if id==len(c) or largest==M:
            break
        while(id<len(c) and c[-i]+c[id]<=M):
            largest=max(largest,c[-i]+c[id])
            id+=1
    print(largest)

# Optimized solution
import bisect

while(1):
    [N,M]=[int(x) for x in input().split()]
    if N==0:
        break
    a=[0 for x in range(N+1)]
    for i in range(N):
        a[i+1]=int(input())
    #b=sorted([x+y for x in a for y in a])
    #c=[]
    #for i in range(1,len(b)):
    #    if b[i]>M:
    #        break
    #    elif b[i-1]!=b[i]:
    #        c.append(b[i-1])
    b=[a[x]+a[y] for x in range(N+1) for y in range(x,N+1)]
    #c=f7(b)
    c=sorted(b)
    #print c
    largest=0
    id=0
    st=len(c)-bisect.bisect(c,M)+1
    #print st
    for i in range(st,len(c)+1):
        if id==len(c):
            break
        while(id<len(c) and c[-i]+c[id]<=M):
            #print c[-i],c[id],c[-i]+c[id]
            largest=max(largest,c[-i]+c[id])
            id+=1
    print(largest)
# Original solution
def solve():
  while True:
    n,m = list(map(int,input().split()))
    if not n and not m: break
    lst = []
    lst2 = []
    lst = [int(eval(input())) for _ in range(n)]
    lst.append(0)
    lst2 = [i + j for i in lst for j in lst if i <= j]
    #for i in lst:
    #  for j in lst:
    #    if i + j <= m:
    #      lst2.append(i + j)
    #lst2 = list(set(lst2 + lst))
    lst2.sort()
    def binary(x, left, right):
      center = (left + right) // 2
      length = right - left + 1
      v = lst2[center]
      if length == 1 or length == 2:
        if v > x:
          return center - 1
        else:
          return center
      elif v == x: return x
      elif v < x: return binary(x, center, right)
      elif v > x: return binary(x, left, center)
    A = []
    #ans = 0
    for i in lst2:
      if i + lst2[-1] <= m:
        A.append(i + lst2[-1])
        #ans = max(ans, i + lst2[-1])
      elif i <= m:
        A.append(i + lst2[binary(m - i, 0 , len(lst2) - 1)])
        #ans = max(ans, i + lst2[binary(m - i, 0, len(lst2) - 1)])
      else:
        break
    print((max(A)))
    #print(ans)
solve()




# Optimized solution
def solve():
  while True:
    n,m = list(map(int,input().split()))
    if not n and not m: break
    
    lst = [int(eval(input())) for _ in range(n)]
    lst.append(0)
    lst = sorted(lst)
    lst2 = [i + j for i in lst for j in lst if i <= j]
    lst2 = sorted(lst2)
    A = []
    index = len(lst2) - 1
    for i in lst2:
      if i + lst2[-1] <= m:
        A.append(i + lst2[-1])
      elif i <= m:
        while True:
          if i + lst2[index] <= m:
            break
          index -= 1
        A.append(i + lst2[index])
      else:
        break
    print((max(A)))
solve()
# Original solution
def calc(s, count):
    global m, r, nums
    if s >= m or count > 4:
        return
    else:
        if r < s:
            r = s
        for n in nums:
            calc(s + n, count + 1)

while True:
    n, m = [int(n) for n in input().split()]
    if n == 0 and m == 0:
        break
    else:
        r = 0
        nums = [int(input()) for i in range(n)]
        calc(0, 0)
        print(r)

# Optimized solution
import bisect

while True:
    n, m = [int(n) for n in input().split()]
    if n == 0 and m == 0:
        break
    else:
        r = 0
        nums = [int(input()) for i in range(n)] + [0]
        temp = sorted(set([x + y for x in nums for y in nums if x + y < m]))
        for num in temp:
            index = bisect.bisect_left(temp, m - num)
            if r < num + temp[index - 1]:
                r = num + temp[index - 1]
        print(r)
# Original solution
import itertools
while 1:
	N,M = list(map(int,input().split()))
	if N == 0: break
	P = set([int(input()) for i in range(N)])
	ans = 0
	for i in range(2,5):
		for p in itertools.combinations_with_replacement(P,i):
			if ans < sum(p) <= M:
				ans = sum(p)
	print(ans)

# Optimized solution
from bisect import *
while 1:
	N,M = list(map(int,input().split()))
	if N == 0: break
	P = [int(input()) for i in range(N)] + [0]
	P = sorted([i+j for i in P for j in P])
	s = bisect(P,M) - 1
	print(max(i + P[bisect(P,M-i) - 1] for i in P[:s]))
# Original solution
from bisect import *
while 1:
	N,M = list(map(int,input().split()))
	if N == 0: break
	P = [int(input()) for i in range(N)] + [0]
	P = sorted([i+j for i in P for j in P])
	s = bisect(P,M) - 1
	print(max(i + P[bisect(P,M-i) - 1] for i in P[:s]))

# Optimized solution
from bisect import *
while 1:
	N,M = list(map(int,input().split()))
	if N == 0: break
	P = [int(input()) for i in range(N)] + [0]
	P = sorted(set(i+j for i in P for j in P))
	s = bisect(P,M) - 1
	print(max(i + P[bisect(P,M-i) - 1] for i in P[:s]))
# Original solution
from bisect import bisect_right

while True:
    n, m = list(map(int, input().split()))
    if not n:
        break

    ps = [0] + sorted(int(eval(input())) for _ in range(n))

    p2 = set()
    for i, pi in enumerate(ps):
        for pj in ps[i:]:
            if pi + pj > m:
                break
            p2.add(pi + pj)

    p2 = sorted(p2)

    max_s = 0
    for pi in p2:
        j = bisect_right(p2, m - pi)
        s = pi + p2[j - 1]
        if max_s < s:
            max_s = s
    print(max_s)

# Optimized solution
from bisect import bisect_right

while True:
    n, m = list(map(int, input().split()))
    if not n:
        break

    ps = [0] + sorted(int(eval(input())) for _ in range(n))

    p2 = set()
    for i, pi in enumerate(ps):
        for pj in ps[i:]:
            if pi + pj > m:
                break
            p2.add(pi + pj)

    p2 = sorted(p2)

    print((max(pi + p2[bisect_right(p2, m - pi) - 1] for pi in p2)))
# Original solution
from bisect import *
while 1:
    n, lmt = list(map(int, input().split()))
    if n == 0: break
    p = [eval(input()) for i in range(n)] + [0]
    p = sorted(set(i + j for i in p for j in p))
    s = bisect(p, lmt)
    print(max(i + p[bisect(p[:s], lmt - i) - 1] for i in p[:s]))

# Optimized solution
from bisect import *
while 1:
    n, lmt = list(map(int, input().split()))
    if n == 0: break
    p = [eval(input()) for i in range(n)] + [0]
    p = sorted(set(i + j for i in p for j in p))
    s = bisect(p, lmt)
    print(max(i + p[bisect(p, lmt - i) - 1] for i in p[:s]))
# Original solution
import bisect

while 1:
    n,m=list(map(int,input().split()))
    if n==m==0:break
    p=[0]+[int(input()) for _ in range(n)]
    com=[0]*((n+1)**2)
    for i in range(n+1):
        for j in range(n+1):
            com[(n+1)*i+j]=p[i]+p[j]
    com.sort()
    ans=0
    for i in range(n+1):
        for j in range(n+1):
            if m-com[(n+1)*i+j]<0:continue
            index=bisect.bisect_left(com,m-com[(n+1)*i+j])
            if index==len(com):continue
            if com[index]>m-com[(n+1)*i+j]:
                if index==0:continue
                else:
                    index-=1
            ans=max(ans,com[(n+1)*i+j]+com[index])
    print(ans)

# Optimized solution
import bisect

while 1:
    n,m=list(map(int,input().split()))
    if n==m==0:break
    p=[0]+[int(input()) for _ in range(n)]
    com=[None]*((n+1)**2)
    for i in range(n+1):
        for j in range(n+1):
            com[(n+1)*i+j]=p[i]+p[j]
    com.sort()
    ans=0
    for i in range(n+1):
        for j in range(n+1):
            tmp=m-com[(n+1)*i+j]
            if tmp<0:continue
            index=bisect.bisect_left(com,tmp)
            if index==(n+1)**2:continue
            if com[index]>tmp:
                if index==0:continue
                else:
                    index-=1
            ans=max(ans,com[(n+1)*i+j]+com[index])
        if ans==m:
            break
    print(ans)
# Original solution
import bisect

while 1:
    n,m=list(map(int,input().split()))
    if n==m==0:break
    p=[0]+[int(input()) for _ in range(n)]
    com=[None]*((n+1)**2)
    for i in range(n+1):
        for j in range(n+1):
            com[(n+1)*i+j]=p[i]+p[j]
    com.sort()
    ans=0
    for i in range(n+1):
        for j in range(n+1):
            tmp=m-com[(n+1)*i+j]
            if tmp<0:continue
            index=bisect.bisect_left(com,tmp)
            if index==(n+1)**2:continue
            if com[index]>tmp:
                if index==0:continue
                else:
                    index-=1
            ans=max(ans,com[(n+1)*i+j]+com[index])
        if ans==m:
            break
    print(ans)

# Optimized solution
import bisect

def solve(n,m):
    p=[0]+[int(input()) for _ in range(n)]
    com=[None]*((n+1)**2)
    for i in range(n+1):
        for j in range(n+1):
            com[(n+1)*i+j]=p[i]+p[j]
    com.sort()
    ans=0
    for i in range(n+1):
        for j in range(n+1):
            tmp=m-com[(n+1)*i+j]
            if tmp<0:continue
            index=bisect.bisect_left(com,tmp)
            if index==(n+1)**2:continue
            if com[index]>tmp:
                if index==0:continue
                else:
                    index-=1
            ans=max(ans,com[(n+1)*i+j]+com[index])
        if ans==m:
            break
    return ans

while 1:
    n,m=list(map(int,input().split()))
    if n==m==0:break
    print((solve(n,m)))
# Original solution
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n):

    def s(n):
        return (int(26 ** n) - 1) * 26 // 25

    d = 0
    for i in range(1, 100): 
        if s(i-1) + 1 <= n and n <= s(i):
            d = i
            break

    m = n - s(d- 1) - 1
    ks = []
    while True:
        k = m // 26
        r = m % 26
        ks.append(r)
        if k == 0:
            break
        m = k

    ks.reverse()

    names = 'abcdefghijklmnopqrstuvwxyz'
    result = []
    for k in ks:
        result.append(names[k])

    pad_size = d - len(result)
    result = ["a"] * pad_size + result

    return ''.join(result)
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


# Optimized solution
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n):

    def s(n):
        return (int(26 ** n) - 1) * 26 // 25

    d = 0
    for i in range(1, 100): 
        if s(i-1) + 1 <= n and n <= s(i):
            d = i
            break

    # 26 + 26**2 + 1   26 + 26**2 * 26**3    s(3)
    # aaa              zzz
    # 1から26**3まで
    # 1ずらして
    # 0から26**3 - 1までとすると
    # 26進数で
    # aが0でzが25に対応するようになる

    m = n - s(d- 1) - 1
    ks = []
    while True:
        k = m // 26
        r = m % 26
        ks.append(r)
        if k == 0:
            break
        m = k

    ks.reverse()

    names = 'abcdefghijklmnopqrstuvwxyz'
    result = []
    for k in ks:
        result.append(names[k])

    pad_size = d - len(result)
    result = ["a"] * pad_size + result

    return ''.join(result)
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
# Original solution
import string

# 1千兆 + 1
N = int(eval(input()))
n_digits = len(str(1000000000000001))
letters = string.ascii_lowercase

x = N - 1
ans = []
# while True:
#     mod = x % 26
#     ans = [ mod ] + ans
#     x = x // 26
#     if x <= 0:
#         if ans[0] == 0:
#             ans = [0] + ans
#         break

# print(ans)
# print("".join([ letters[v] for v in ans ]))

while True:
    mod = x % 26
    div = x // 26
    
    ans.append(mod)
    if div == 0:
        break
    x = div - 1

ans = ans[::-1]
# print(ans)
print(("".join([ letters[v] for v in ans ])))

# Optimized solution
import string

# 1千兆 + 1
N = int(eval(input()))
n_digits = len(str(1000000000000001))
letters = string.ascii_lowercase

x = N - 1
ans = []
# while True:
#     x -= 1
#     mod = x % 26
#     ans = [ mod ] + ans
#     x = x // 26
#     if x <= 0:
#         break

# print(ans)
# print("".join([ letters[v] for v in ans ]))

while True:
    # x -= 1
    mod = x % 26
    div = x // 26
    # x = x // 26
    
    ans.append(mod)
    if div == 0:
        break
    x = div - 1

ans = ans[::-1]
print(("".join([ letters[v] for v in ans ])))
# Original solution
import string

# 1千兆 + 1
N = int(eval(input()))
n_digits = len(str(1000000000000001))
letters = string.ascii_lowercase

x = N - 1
ans = []
# while True:
#     x -= 1
#     mod = x % 26
#     ans = [ mod ] + ans
#     x = x // 26
#     if x <= 0:
#         break

# print(ans)
# print("".join([ letters[v] for v in ans ]))

while True:
    # x -= 1
    mod = x % 26
    div = x // 26
    # x = x // 26
    
    ans.append(mod)
    if div == 0:
        break
    x = div - 1

ans = ans[::-1]
print(("".join([ letters[v] for v in ans ])))

# Optimized solution
import string

# 1千兆 + 1
N = int(eval(input()))
n_digits = len(str(1000000000000001))
letters = string.ascii_lowercase

# x = N - 1
x = N
ans = []
# while True:
#     x -= 1
#     mod = x % 26
#     ans = [ mod ] + ans
#     x = x // 26
#     if x <= 0:
#         break

# print(ans)
# print("".join([ letters[v] for v in ans ]))

while True:
    x -= 1
    mod = x % 26
    # div = x // 26
    x = x // 26
    
    ans.append(mod)
    # if div == 0:
    if x == 0:
        break
    # x = div - 1

ans = ans[::-1]
print(("".join([ letters[v] for v in ans ])))
# Original solution
import sys
input = sys.stdin.readline
import string
import sys
import math

ALPHABET = ["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"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])
def main():
    N = int(eval(input()))
    ans = alphabet_decimal(N).lower()
    print(ans)
if __name__ == "__main__":
    main()

# Optimized solution
import sys
input = sys.stdin.readline
import string
def main():
    def f(n):
        if n == -1:return
        a, b = divmod(n, 26)
        ans.append(string.ascii_lowercase[b])
        f(a-1)

    N = int(eval(input()))
    ans = []
    f(N-1)
    print(("".join(ans[::-1])))
if __name__ == "__main__":
    main()
# Original solution
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(eval(input()))
komoji = [chr(i) for i in range(97, 97+26)]

ans = ""
# print(N)
while True:
    q, mod = divmod(N, 26)
    ans = komoji[mod-1] + ans
    # print("q: {} mod: {} ans: {}".format(q, mod, ans))
    if mod == 0:
        q = q - 1
    N = q
    if q == 0:
        break
print(ans)

# Optimized solution
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(eval(input()))
komoji = [chr(i) for i in range(97, 97+26)]

ans = ""
# print(N)
while True:
    N -= 1
    q, mod = divmod(N, 26)
    ans = komoji[mod] + ans
    # print("q: {} mod: {} ans: {}".format(q, mod, ans))
    if q == 0:
        break
    N = q
print(ans)
# Original solution
s = input()
n = int(s)

def main(n):
	d = 1
	n -= 1
	while n - 26**d >= 0:
		n -= 26**d
		d += 1
	ret = ''
	for i in range(d):
		ret += chr((n%26)+ord('a'))
		n //= 26
	return ret[::-1]

print(main(n))


# Optimized solution
a = int(eval(input()))
s = []
ret = ['z', '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',
       ]
while a > 0:
    a -= 1
    shang = int(a / 26)
    yushu = int(a % 26)
    # print(shang, yushu)
    s.append(yushu+1)
    a = shang

s.reverse()
# print(s)
v = ''
for i in range(len(s)):
    v += ret[s[i]]
print(v)
# Original solution
num = int(eval(input()))
s = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
while num > 26:
    num, rest = divmod(num, 26)
    ans += s[rest - 1]
    if rest == 0:
        num -= 1
    #num -= 1
    #print(ans, num, rest)
    
ans += s[num - 1]
print((ans[::-1]))


# Optimized solution
num = int(eval(input()))
s = 'abcdefghijklmnopqrstuvwxyz'
ans = ''

while num > 0:
    num, rest = divmod(num, 26)
    ans += s[rest - 1]
    if rest == 0:
        num -= 1

print((ans[::-1]))
# Original solution
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(eval(input()))

print((num2alpha(n).lower()))

# Optimized solution
n = int(eval(input()))

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print((num2alpha(n).lower()))