def solve(): n,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) sA = set(A) sB = set(B) sames = [] for b in B: if b in sA: sames.append(b) if n == 0 or m == 0: for a in A: print(f"Red {a}") for b in B: print(f"Blue {b}") return if sames == []: print("No") return print("Yes") for a in A: if a not in sB: print(f"Red {a}") l = sames.pop() print(f"Red {l}") print(f"Blue {l}") for b in B: if b not in sA: print(f"Blue {b}") for i,l in enumerate(sames): if i%2: print(f"Red {l}") print(f"Blue {l}") else: print(f"Blue {l}") print(f"Red {l}") return t = int(input()) for _ in range(t): solve()