#H,W=map(int, input().split()) N=int(input()) S,T=input().split() A=list(map(int, input().split())) s,t=len(S),len(T) M=2*10**5+10 dp=[10**6]*(M+1) P=[-1]*(M+1) dp[0]=0;P[0]=0 for i in range(1,M+1): nex=s*i if nex>M: break dp[nex]=i;P[nex]=0 for i in range(1,M+1): if dp[i]==10**6: if i-t>=0 and dp[i-t]!=10**6: dp[i]=dp[i-t] P[i]=P[i-t]+1 for a in A: F=[] for i in range(dp[a]): F.append(S) for i in range(P[a]): F.append(T) print(*F)