def solve_pattern(N, S, T, A): lenS = len(S) lenT = len(T) for target_len in A: S_count = target_len // lenS ans = [S] * S_count current_len = lenS * S_count while current_len < target_len: ans.append(T) current_len += lenT if current_len > target_len: remove_count = (current_len - target_len) // lenS ans[:remove_count] = [""] * remove_count filtered_ans = list(filter(None, ans)) print(" ".join(filtered_ans)) def main(): N = int(input()) S, T = input().split() A = list(map(int, input().split())) solve_pattern(N, S, T, A) if __name__ == "__main__": main()