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())) if len(S)==len(T): for i in range(N): ans=[] for j in range(A[i]//len(S)): ans.append(S) print(*ans) exit() if len(S)==1: for i in range(N): ans=[S]*A[i] print(*ans) s=len(S) t=len(T) g=gcd(max(s,t),min(s,t)) s=s//g t=t//g for i in range(N): a=A[i]//g h=(a*pow(t,s-2,s))%s ans=[T]*h a-=(t*h) for j in range(a//s): ans.append(S) print(*ans)