T = int(input()) NN = [] MM = [] AA = [] BB = [] for _ in range(T): n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) NN.append(n) MM.append(m) AA.append(a) BB.append(b) for i in range(T): try: N = NN[i] M = MM[i] A = AA[i] B = BB[i] if N>0 and M>0: setA = set(A) setB = set(B) same = [] diff = [] for b in B: if b in setA: same.append(b) else: diff.append(b) if len(same)==0: print("No") continue print("Yes") for d in diff: print("Blue", d) for i, s in enumerate(same): if i%2==0: print("Blue", s) print("Red", s) if i==0: for a in setA: if a not in setB: print("Red", a) else: print("Red", s) print("Blue", s) elif N>0: print("Yes") for a in A: print("Red", a) elif M>0: print("Yes") for b in B: print("Blue", b) else: print("Yes") except: print("No")