#include #include #include #include #include int main() { std::cin.tie(nullptr)->sync_with_stdio(false); int N; std::string S, T; std::cin >> N >> S >> T; const int MAX{200010}; std::vector dp(MAX, -1); dp[0] = 0; for (int i{} ; i < MAX ; i++) { if (i + (int)S.size() < MAX and dp[i + S.size()] < dp[i] + 1) { dp[i + S.size()] = dp[i] + 1; } if (i + (int)T.size() < MAX and dp[i + T.size()] < dp[i]) { dp[i + T.size()] = dp[i]; } } auto get{[&](int x) -> std::vector { std::vector res; assert(dp[x] != -1); for (int i{} ; i < dp[x] ; i++) res.push_back(S); int remain{x - dp[x] * (int)S.size()}; assert(remain >= 0 and remain % (int)T.size() == 0); while (remain) { res.push_back(T); remain -= (int)T.size(); } return res; }}; for (int i{} ; i < N ; i++) { int A; std::cin >> A; auto res{get(A)}; for (int j{} ; j < (int)res.size() ; j++) std::cout << res[j] << (j + 1 == (int)res.size() ? '\n' : ' '); } }