T = int(input()) while T > 0: T -= 1 K, X, Y = map(int, input().split()) A = list(map(int, input().split())) P = list(map(int, input().split())) nim = 0 for k in range(K): nim ^= A[k] % (P[k]+1) if nim == 0: if Y >= X: print('C') else: print('Z') else: if Y >= X + nim: print('C') else: print('Z')