def gcd(a,b): if b==0: return a else: return gcd(b,a%b) N=int(input()) S,T=list(map(str,input().split())) A=list(map(int,input().split())) s=len(S) t=len(T) for i in range(N): m=A[i] ans=[] while m%len(S)!=0: ans.append(T) m-=t while m>0: ans.append(S) m-=s print(*ans)