#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { int N; cin >> N; string S, T; cin >> S >> T; vector A(N); for (int i = 0; i < N; i++) cin >> A[i]; int s = ssize(S), t = ssize(T); for (int i = 0; i < N; i++) { for (int j = A[i] / s; j >= 0; j--) { int rem = A[i] - j * s; if (rem % t == 0) { int k = rem / t; while (j--) cout << S << ' '; while (k--) cout << T << ' '; cout << endl; break; } } } }