from bisect import bisect_left mi=lambda: map(int,input().split()) mi1=lambda: map(lambda x: int(x)-1,input().split()) li=lambda: list(mi()) li1=lambda: list(mi1()) ii=lambda: int(input()) def buildCompressedElementsList(a,comp=[]): return sorted(set(a+comp)) def compress(a,comp): for i in range(len(a)): a[i]=bisect_left(comp,a[i]) def countListElements(a,n): # assert all(0 <= x < n for x in a) res=[0]*n for x in a: res[x]+=1 return res printRed=lambda x: print("Red", x+1) printBlue=lambda x: print("Blue", x+1) def printPair(x,redFirst=True): if redFirst: printRed(x) printBlue(x) else: printBlue(x) printRed(x) def solve(): n,m=mi() a=li1() b=li1() if n==0: print("Yes") for x in b: printBlue(x) return if m==0: print("Yes") for x in a: printRed(x) return setB=set(b) checkAnyPair=lambda: any(x in setB for x in a) if not checkAnyPair(): print("No") return comp=buildCompressedElementsList(a) comp=buildCompressedElementsList(b,comp) compress(a,comp) compress(b,comp) s=len(comp) cntA=countListElements(a,s) cntB=countListElements(b,s) red=[] blue=[] pair=[] for i in range(s): mn=min(cntA[i],cntB[i]) pair+=[i for _ in range(mn)] if cntA[i]>cntB[i]: red+=[i for _ in range(cntA[i]-cntB[i])] else: blue+=[i for _ in range(cntB[i]-cntA[i])] print("Yes") # step 1: eat red cards which doesn't has partner for x in red: printRed(comp[x]) # step 2.1: eat a pair of cards (it's guaranteed that there is at least one pair of cards, and this changes previous color to blue) printPair(comp[pair[0]], True) # step 2.2: eat blue cards which doesn't has partner for x in blue: printBlue(comp[x]) # step 2.3: eat the other pairs of cards for i in range(1,len(pair)): printPair(comp[pair[i]],(i&1)==0) for _ in range(ii()): solve()