for _ in range(int(input())): n,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) if m==0: print("Yes") for v in a: print("Red",v) continue if n==0: print("Yes") for v in b: print("Blue",v) continue c = set(a)&set(b); d = []; e = []; f = 0 for v in a: if v not in c: d.append(v) for v in b: if v not in c: e.append(v) if not c: print("No"); continue print("Yes") for v in d: print("Red",v) v = c.pop(); print("Red",v); print("Blue",v) for v in e: print("Blue",v) for v in c: if f: print("Red",v); print("Blue",v) else: print("Blue",v); print("Red",v) f ^= 1