T = int(input()) for _ in range(T): N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) 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) else: print("Yes") for b in B: print("Blue", b)