T = int(input()) for t in range(T): N,M = map(int,input().split()) A = set(map(int,input().split())) B = set(map(int,input().split())) CO = A & B AO = A - CO BO = B - CO NC = len(CO) NA = len(AO) NB = len(BO) if NC == 0 and NA * NB > 0: print("No") continue print("Yes") for i in AO: print("Red",i) st = 0 for i in CO: if st == 0: print("Red",i) print("Blue",i) else: print("Blue",i) print("Red",i) st ^= 1 for i in BO: print("Red",i)