#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; string s,t; cin >> s >> t; int n = s.size(),m = t.size(); vector dp(200001,-1001001001); dp.at(0) = 0; for(int i=1; i<=200000; i++){ if(i >= n) dp.at(i) = dp.at(i-n)+1; if(i >= m) dp.at(i) = max(dp.at(i),dp.at(i-m)); } while(N--){ int a; cin >> a; int Ss = dp.at(a); bool first = true; a -= Ss*n; a /= m; while(Ss--){ if(!first) cout << " "; first = false; cout << s; } while(a--){ if(!first) cout << " "; first = false; cout << t; } cout << "\n"; } }