#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t N, i, j; cin >> N; string S, T; cin >> S >> T; vector A(N); for (i = 0; i != N; ++i) cin >> A[i]; vector> ans(N); for (i = 0; i != N; ++i) for (j = 0; T.size() * j <= A[i]; ++j) if ((A[i] - T.size() * j) % S.size() == 0) { ans[i] = { (A[i] - T.size() * j) / S.size(), j }; break; } for (i = 0; i != N; ++i) { if (ans[i].first != 0) { cout << S; for (j = 1; j < ans[i].first; ++j) cout << ' ' << S; for (j = 0; j < ans[i].second; ++j) cout << ' ' << T; } else { cout << T; for (j = 1; j < ans[i].second; ++j) cout << ' ' << T; } cout << '\n'; } return 0; }