AT_abc469_g [ABC469G] K-nacci Operations

Description

You are given $ K $ strings $ S_1, S_2, \ldots, S_K $ consisting of `a` and `b`. Also, for an integer $ i > K $ , define the string $ S_i $ as the concatenation of $ S_{i-1}, S_{i-2}, \ldots, S_{i-K} $ in this order. You perform the following operation on a string $ T $ . - Perform the following operations for $ j = 1, 2, \ldots, |S_N| $ in order, where $ |S_N| $ is the length of $ S_N $ . - If the $ j $ -th character of $ S_N $ is `a`, move the first character of $ T $ to the end. - If the $ j $ -th character of $ S_N $ is `b`, reverse $ T $ entirely. That is, reverse the order of the characters of $ T $ . Find the string $ T $ after the series of operations.

Input Format

The input is given from Standard Input in the following format: > $ K $ $ S_1 $ $ S_2 $ $ \vdots $ $ S_K $ $ N $ $ T $

Output Format

Output the answer.

Explanation/Hint

### Sample Explanation 1 $ S_1 = $ `a`, $ S_2 = $ `aa`, $ S_3 = $ `b`, $ S_4 = $ `baaa`, and $ S_5 = $ `baaabaa`. Through the operations, the string $ T $ changes as `abc` → `cba` → `bac` → `acb` → `cba` → `abc` → `bca` → `cab`, so the string $ T $ after the series of operations is `cab`. ### Constraints - $ 2 \leq K \leq 100 $ - $ K $ is an integer. - $ S_i $ is a non-empty string consisting of `a` and `b`. $ (1 \leq i \leq K) $ - The sum of the lengths of $ S_1, S_2, \ldots, S_K $ is at most $ 2 \times 10^5 $ . - $ 1 \leq N \leq 10^{18} $ - $ N $ is an integer. - $ T $ is a string consisting of lowercase English letters with length between $ 1 $ and $ 2 \times 10^5 $ , inclusive.