N=int(input()) S,T=input().split() A=list(map(int,input().split())) v=[0]*(3*10**5) a=len(S) b=len(T) result=[] for i in range(N): result=[] x=A[i] z=0 for y in range(x+1): if y*a>x: break if (x-y*a)%b==0: z=y w=(x-z*a)//b for j in range(z): result.append(S) for j in range(w): result.append(T) print(*result)