import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n = ni() s, t = input().split() S, T = len(s), len(t) a = na() from math import gcd g = gcd(S, T) S //= g T //= g for i in range(n):#Sx+Ty = X a[i] //= g y = a[i] * pow(T, -1, S) % S x = (a[i] - y * T) // S print(*([s] * x + [t] * y))