#include using namespace std; int main(){ cin.tie(nullptr)->sync_with_stdio(false); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif int _N; cin >> _N; string S, T; cin >> S >> T; const int N = S.size(); const int M = T.size(); for(int i = 0; i < _N; ++i){ int x; cin >> x; long long max_cnt = 0; for(long long y = 0; x >= y * M ;++y){ if((x - y * M) % N == 0){ max_cnt = x - y * M; max_cnt /= N; break; } } for(int t = 0; t < max_cnt; ++t) cout << S << ' '; for(int t = 0; t < (x - max_cnt * N) / M; ++t) cout << T << ' '; cout << '\n'; } return 0; }