import sys input = sys.stdin.readline N=int(input()) S,T=input().split() A=list(map(int,input().split())) LS=len(S) LT=len(T) for a in A: k=a//len(S) MAX=0 for i in range(k+1): if (a-LS*i)%LT==0: MAX=i kt=(a-LS*MAX)//LT X=[S]*MAX + [T]*kt print(*X)