n=int(input()) s,t=input().split() a=list(map(int,input().split())) ans=[] for i in a: mx=-1 for j in range(i+1): if len(s)*j<=i and (i-len(s)*j)%len(t)==0: mx=max(mx,j) assert mx!=-1 ans.append(" ".join([s]*mx+[t]*((i-len(s)*mx)//len(t)))) for i in ans: print(i)