n = int(input()) s, t = list(map(str, input().split())) A = list(map(int, input().split())) for i in range(n): tmp = A[i] // len(s) while tmp >= 0: if (A[i] - tmp * len(s)) % len(t) == 0: ans = [] for j in range(tmp): ans.append(s) for j in range((A[i] - tmp * len(s)) // len(t)): ans.append(t) print(*ans) break tmp -= 1