#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; string S, T; cin >> N >> S >> T; int sum = 0; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } vector maxS(sum + 1, -1); for (int i = 0; i * S.size() <= sum; i++) { maxS[i * S.size()] = i; } for (int i = T.size(); i <= sum; i++) { maxS[i] = max(maxS[i], maxS[i - T.size()]); } for (int i = 0; i < N; i++) { assert(maxS[A[i]] != -1); int K = maxS[A[i]]; vectorans; for (int j = 0; j < K; j++) { ans.push_back(S); A[i] -= S.size(); } while (A[i] > 0) { ans.push_back(T); A[i] -= T.size(); } assert(A[i] == 0); for (int j = 0; j < int(ans.size()); j++) { cout << ans[j] << " \n"[j + 1 == ans.size()]; } } }