#include #include #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) using namespace std; using namespace atcoder; using ll = long long; const ll mod = 998244353; using mint = modint998244353; using Graph = vector>>; const vector dx = {1,0,-1,0}, dy = {0,1,0,-1}; pair song(int a, int b, int n){ for(int x = int(n/a); x >= 0; x--){ int y = n - a*x; if(y % b == 0) return(make_pair(x,y/b)); } return(make_pair(-1,-1)); } int main(){ // input int N; string S,T; cin >> N >> S >> T; vector A(N); for(int i = 0; i < N; i++) cin >> A[i]; vector> ans(N); for(int i = 0; i < N; i++){ auto [x,y] = song(S.size(),T.size(),A[i]); for(int j = 0; j < x; j++) ans[i].push_back(S); for(int j = 0; j < y; j++) ans[i].push_back(T); } // output for(int i = 0; i < N; i++){ for(int j = 0; j < ans[i].size(); j++){ if(j) cout << " "; cout << ans[i][j]; } cout << endl; } }