n = int(input()) s, t = list(map(str, input().split())) A = list(map(int, input().split())) for i in range(n): a = A[i] - len(t) b = a // len(s) c = (A[i] - len(s) * b) // len(t) for j in range(b): print(s, end=" ") for j in range(c): print(t, end=" ") print()