#include using namespace std; int main(){ int T; cin >> T; for (int i = 0; i < T; i++){ int K; long long X, Y; cin >> K >> X >> Y; vector A(K); for (int j = 0; j < K; j++){ cin >> A[j]; } vector P(K); for (int j = 0; j < K; j++){ cin >> P[j]; } long long S = 0; for (int j = 0; j < K; j++){ S ^= A[j] % (P[j] + 1); } if (X > Y){ cout << 'Z' << endl; } else if (X == Y){ if (S == 0){ cout << 'C' << endl; } else { cout << 'Z' << endl; } } else if (Y - X == 1){ if (S == 1){ cout << 'C' << endl; } else { cout << 'Z' << endl; } } else { if (S <= Y - X){ cout << 'C' << endl; } else { cout << 'Z' << endl; } } } }