N=int(input()) S,T=input().split() lenS=len(S) lenT=len(T) A=list(map(int,input().split())) for a in A: lencount=0 ans=[] check="" tmp=a//lenS lencount+=lenS*tmp if lencounta: for i in range((len(check)-a)//lenS): ans[i]="" print(*ans) else: for i in range((a-len(check))//lenT): ans.append(T) print(*ans)