/* ⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⣰⣿⣿⣿⡟⠁⠀⣠⣾⣿⣿⣿⣿⡿⠟⣿⣿⣿⣿⣿⡿⠿⠛⠛⠉⠉⠙⠛⠻⠿⣿⣿⣿⣿⣿⣿⣶⣤⣀⡀⠀⠀⠀⠹⣿⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⢰⣿⣿⣿⡏⠀⠀⣼⣿⣿⣿⣿⠟⠉⣠⣾⣿⠿⠛⣉⣀⣤⣤⣴⣶⣶⣶⣶⣶⣤⣀⡀⠉⠙⠻⣿⣿⣿⣿⣿⣿⣄⡀⠀⠀⠈⠛
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠈⣿⣿⣿⡇⠀⣼⣿⣿⣿⡿⢃⣤⣾⣿⣫⣵⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣶⣤⡤⠄
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠘⣿⣿⡇⢰⣿⣿⣿⡿⠾⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣦⠀⠀⢻⣿⣿⣿⣿⣧⡀⠀⠀⠀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⣼⣦⡘⣿⣧⡿⢻⠙⠉⠀⢀⣀⣴⣿⣿⡿⠉⠀⠀⠉⠉⠙⠻⣿⣎⢿⣿⣿⣿⣿⣧⠙⣿⣟⢿⣧⡀⠀⢻⣿⣿⣿⣿⣿⣦⡀⠀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡻⢋⣾⠚⠋⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣀⠀⠀⠀⠀⣀⣴⣾⣿⠿⡌⢿⣿⣿⣿⣿⣧⠘⢿⡄⠉⠻⣄⠀⢻⣿⣏⠛⠛⠻⢿⣄
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⣿⠟⠀⠀⠀⠀⠀⠀⠐⠉⠀⢹⣿⣿⣿⣤⣤⣴⣾⣿⣿⣿⠁⠀⠛⠜⣿⣿⣿⣿⣿⣧⠈⢿⡄⢠⠈⠃⠀⠻⣿⣧⡀⠀⠀⣈
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⡿⠿⠛⢻⣷⣶⣿⣿⡘⣿⣿⠹⣿⣿⠀⠈⢿⣄⢳⣤⡀⠀⠙⠛⠿⣆⠀⠘
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⣾⣿⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⢻⡿⠛⠉⠉⣀⡀⠠⠄⠀⠀⠙⠿⣇⢹⣿⡇⢻⡟⢸⡀⠈⢿⣮⣿⣿⣶⣦⣄⣀⣀⣀⣀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣫⣾⣿⡟⠀⠀⠀⠀⠀⠀⠀⢀⠟⢻⡿⠁⠀⢀⡤⠚⠁⠀⠀⠀⠀⠀⠀⠀⠀⢀⢰⣿⣿⠈⢁⣿⡇⠀⣾⣿⣿⣿⣿⣿⣿⣿⡿⠟⣉
⢸⣿⣿⣿⣿⣿⣿⣿⣛⣩⠾⠿⠿⠿⢿⡕⢆⠀⠀⠀⠀⠀⠊⠀⠈⠀⣠⠔⣋⣠⣤⣄⣉⣀⡀⠀⠀⠀⠀⠀⢈⣾⣿⣿⡆⣼⣿⠇⠰⣿⣿⣿⣟⠛⢛⣉⣡⣴⣾⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⡿⣄⣧⡀⠀⢠⠀⠑⢤⠴⢋⠁⡾⢻⡿⣿⣿⣯⠛⠛⠲⠤⠀⠀⢠⣾⣿⣿⣿⣿⣿⣿⢠⠄⠈⢻⣿⣿⣆⠘⢿⣿⣿⠛⠉
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣹⣿⢿⡃⣿⣦⡀⠀⠀⠀⠀⠀⢠⠇⣿⣇⢀⣿⣿⡇⠀⠀⠀⠀⣀⣾⣿⣿⣿⣿⣿⣿⠇⠀⡀⢄⠀⠩⠻⢿⣷⡌⠻⢿⣧⠀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣗⢻⣼⣯⠄⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⡿⠃⠀⠀⠀⢠⣾⣿⣿⣿⠿⢋⣿⠟⠀⠑⠈⠀⠁⡀⠀⣼⣿⣿⣶⣤⣽⣇
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣼⣿⡥⠙⠟⠄⠀⠀⠀⠀⠀⠀⠀⠀⣉⠩⠔⠀⠀⢀⣼⠿⠟⠋⠁⠀⠀⣸⠏⠀⡀⠄⠠⠁⠌⠀⣰⣿⣿⡿⣱⣷⣿⡻
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣋⣐⣿⢯⡇⠩⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠉⠁⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⣤⠀⠀⢀⣾⣿⣿⣿⠳⠿⣿⣿⡿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⡇⢀⣶⣿⣿⣿⣿⣿⣶⣤⡤⠄⣠
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡆⠢⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠋⠀⠇⠘⠛⣿⣿⣿⣿⡿⢛⣩⣴⣾⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⢀⣔⠂⠈⢑⡇⠿⣿⣿⣿⣷⡘⢿⣿⣿⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡈⠁⠀⠀⠀⠉⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠐⠰⢶⡃⣔⣼⡅⢁⠜⠙⣛⣻⢿⣮⣛⣿⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⠀⠛⠿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⠀⠀⢀⠀⠀⣳⢻⢸⡼⡦⢁⣴⣾⣿⣿⣧⡻⣿⣿⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⠞⠁⠀⠀⠄⠀⣈⡄⡟⠛⠈⠋⠁⣿⣿⣿⣿⣿⣿⣿⣮⣻⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⢤⡀⣐⠶⠿⠟⠁⢂⣀⠤⠴⠒⠉⣁⡄⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣷⣝
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣁⡠⡐⣄⡇⢰⠂⠉⠉⢀⣀⣤⣴⣶⣿⣿⡧⠀⠀⠐⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣯⣾⣿⡘⣵⠈⡆⠰⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣽⣶⣶⣿⡿⣿⣿⣿⡇⡟⡀⡇⠀⣿⣿⣿⣿⣿⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠉
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠁⠀⠔⠛⠛⠉⠉⠁⣰⣿⣿⣿⣿⣃⣇⠠⠀⣽⣿⣿⣿⠃⠀⠀⠙⠛⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢁⣤⡾⠃⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⡿⠛⢻⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠻⠿⣿⣿⣿⡿⠃⠀⠀⠀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢏⣶⣿⣿⠃⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⠁⠀⠀⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⢻⣥⡀⠀⠀⠀
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢏⣾⣿⣿⡏⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⠀⠀⠀⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣷⡀⠀ */
/*I love CatTuong*/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define fi first
#define se second
#define IN endl
#define CT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define BIT(x, i) (((x) >> (i)) & 1)
#define all(x) (x).begin(), (x).end()
#define MASK(i) (1LL << (i))
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
using namespace std;
const int MAX = 100;
ull comb[MAX + 1][MAX + 1];
void pre() {
for (int i = 0; i <= MAX; ++i) {
comb[i][0] = comb[i][i] = 1;
for (int j = 1; j < i; ++j) {
comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
}
}
}
string solve(int m, int n, int p, ull k) {
int ttl = m + n + p;
string ans = "";
while (ttl > 0) {
if (m > 0) {
ull countX = comb[ttl - 1][m - 1] * comb[n + p][p];
if (k <= countX) {
ans += 'X';
--m;
} else {
k -= countX;
if (n > 0) {
ull countY = comb[ttl - 1][m] * comb[n + p - 1][p];
if (k <= countY) {
ans += 'Y';
--n;
} else {
k -= countY;
ans += 'Z';
--p;
}
} else {
ans += 'Z';
--p;
}
}
} else if (n > 0) {
ull countY = comb[ttl - 1][n - 1] * comb[m + p][p];
if (k <= countY) {
ans += 'Y';
--n;
} else {
k -= countY;
ans += 'Z';
--p;
}
} else {
ans += 'Z';
--p;
}
--ttl;
}
return ans;
}
int main() {
CT
pre();
int m, n, p;
cin >> m >> n >> p;
int Q;
cin >> Q;
vector<ull> q(Q);
for (int i = 0; i < Q; ++i) {
cin >> q[i];
}
for (int i = 0; i < Q; ++i) {
cout << solve(m, n, p, q[i]) << IN;
}
cout<<IN;
cerr<<"Time elapsed: "<<TIME<<".s"<<IN;
return 0;
}