N=int(input()) S,T=map(str,input().split()) A=map(int,input().split()) for a in A: num=a//len(S) while num>=0: if (a-num*len(S))%len(T)==0: ans=[] for _ in range(num): ans.append(S) for _ in range((a-num*len(S))//len(T)): ans.append(T) print(*ans) break num-=1