import sys input = sys.stdin.readline ans = [] for _ in range(int(input())): N,X,Y = map(int,input().split()) A = list(map(int,input().split())) P = list(map(int,input().split())) grundy = 0 for i in range(N): tmp = A[i]%(P[i]+1) grundy ^= tmp if grundy: if Y-grundy-X>=0: ans.append("C") else: ans.append("Z") else: if Y>=X: ans.append("C") else: ans.append("Z") print(*ans,sep="\n")