#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), recov(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; recov[i + S.size()] = 0; } if (i + (int)T.size() < MAX and dp[i + T.size()] < dp[i]) { dp[i + T.size()] = dp[i]; recov[i + T.size()] = 1; } } auto get{[&](int x) -> std::vector { std::vector res; while (x) { if (recov[x] == 0) { res.push_back(S); x -= (int)S.size(); } else if (recov[x] == 1) { res.push_back(T); x -= (int)T.size(); } else { assert(false); } } 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' : ' '); } }