N = int(input()) S, T = input().split() lenS = len(S) lenT = len(T) A = list(map(int, input().split())) for a in A: ans = [] check_len = 0 num_S = a // lenS for _ in range(num_S): ans.append(S) check_len += lenS if check_len < a: ans.append(T) check_len += lenT if check_len > a: excess_len = check_len - a for i in range(excess_len // lenS): ans[i] = "" print(*ans)