#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(),(x).end() #define inf 1e18 #define mod 1000000007 using namespace std; typedef long long llint; typedef long long ll; typedef pair P; ll T; ll k, x, y; ll a[1005], p[1005]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> T; while(T--){ cin >> k >> x >> y; rep(i, 1, k) cin >> a[i]; rep(i, 1, k) cin >> p[i]; ll ans = 0; rep(i, 1, k) ans ^= a[i] % p[i]; if(y-ans >= x) cout << "C" << endl; else cout << "Z" << endl; } return 0; }