n,(s,t) = int(input()),input().split() a,b = len(s),len(t) for v in map(int,input().split()): for i in range(v//b+1): if (v-b*i)%a==0: print(*[s]*((v-b*i)//a)+[t]*i); break