#int-input def II() -> int : return int(input()) def MI() -> int : return map(int, input().split()) class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p0): s+=self.data[r-1] r-=r&-r return s class dsu(): n=1 parent_or_size=[-1 for i in range(n)] def __init__(self,N): self.n=N self.parent_or_size=[-1 for i in range(N)] def merge(self,a,b): assert 0<=a0: result2.append(result[i]) return result2 n = II() s,t = input().split() a = list(MI()) ls,lt = len(s),len(t) def xgcd(a:int, b:int) -> tuple[int,int,int]: #Euclid互除法 """ans = a*x0 + b*y0""" x0, y0, x1, y1 = 1, 0, 0, 1 while b != 0: q, a, b = a // b, b, a % b x0, x1 = x1, x0 - q * x1 y0, y1 = y1, y0 - q * y1 return a, x0, y0 g,x0,y0 = xgcd(ls,lt) ls //= g lt //= g for ai in a: ans = [] bi = ai//g #bi = ls*x0 + lt*y0 y1 = y0*bi x1 = x0*bi ct = y1%ls ans.extend([t]*ct) cs = (bi - ct*lt)//ls ans.extend([s]*cs) print(*ans)