#include #include #include #include #pragma GCC optimize("O3") using namespace std; typedef int64_t ll; const ll MOD = 1000000007; const ll MOD2 = 998244353; void solve() { ll n; scanf("%ld", &n); string s, t; cin >> s >> t; ll T = t.size(), S = s.size(); auto print = [&](ll x) { ll a; for (a = x / S; (x - a * S) % T; a--) ; ll b = (x - a * S) / T; for (ll i = 0; i < a; i++) { printf("%s ", s.c_str()); } for (ll i = 0; i < b; i++) { printf("%s ", t.c_str()); } printf("\n"); }; for (ll i = 0; i < n; i++) { ll x; scanf("%ld", &x); print(x); } } int main() { cout.tie(NULL); cin.tie(NULL); solve(); }