n=int(input()) S,T=input().split() A=list(map(int,input().split())) for a in A: for i in reversed(range(a+1)): if (a-i*len(S))>=0 and (a-i*len(S))%len(T)==0: print(*([S]*i+[T]*((a-i*len(S))//len(T)))) break