#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; } template bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; } template T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; } template T lcm(T a, T b){ return a / gcd(a, b) * b; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; string S, T; cin >> N >> S >> T; int ls = S.size(), lt = T.size(); rep(i, 0, N){ int A; cin >> A; int s, t = 0; while(A >= 0){ if(A % ls == 0){ s = A / ls; break; } A -= lt; ++t; } vector ans; rep(j, 0, s) ans.push_back(S); rep(j, 0, t) ans.push_back(T); rep(j, 0, ans.size()){ cout << ans[j]; cout << (j == int(ans.size() - 1) ? '\n' : ' '); } } return 0; }