#include char s[200005], t[200005]; int a[200005]; int dp[200005]; int main() { int n; scanf("%d", &n); scanf("%s%s", s, t); int ss, tt; for (ss = 0; s[ss] != '\0'; ss++); for (tt = 0; t[tt] != '\0'; tt++); int i, j; for (i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < ss; i++) dp[i] = 0; for (; i < 200005; i++) { if (i % ss > 0) { if (i >= tt) dp[i] = dp[i - tt]; else dp[i] = 0; } else dp[i] = i / ss; } for (i = 0; i < n; i++) { while (dp[a[i]] > 0) { printf("%s", s); a[i] -= ss; if (a[i] > 0) printf(" "); } while (a[i] > 0) { printf("%s", t); a[i] -= tt; if (a[i] > 0) printf(" "); } printf("\n"); } return 0; }