f=lambda:list(map(int,input().split())) for _ in range(int(input())): N,M=f() if N==M==0: input(); input(); print('Yes'); continue elif N==0: input(); B=f(); print('Yes') for i in B: print('Blue '+str(i)) continue elif M==0: A=f(); input(); print('Yes') for i in A: print('Red '+str(i)) continue A=f(); B=f(); P=set(A); matched=set() for i in B: if i in P: matched.add(i) if not len(matched): print('No'); continue if len(matched)==1: print('Yes') if N==1: for i in B: if i not in matched: print('Blue '+str(i)) for i in matched: print('Blue '+str(i)); print('Red '+str(i)) continue else: for i in A: if i not in matched: print('Red '+str(i)) for i in matched: print('Red '+str(i)); print('Blue '+str(i)) for i in B: if i not in matched: print('Blue '+str(i)) continue else: print('Yes') start=matched.pop(); print('Blue '+str(start)); print('Red '+str(start)) for i in A: if i==start: continue if i not in matched: print('Red '+str(i)) next=matched.pop(); print('Red '+str(next)); print('Blue '+str(next)) for i in B: if i==start or i==next: continue if i not in matched: print('Blue '+str(i)) next_is_BL = True while len(matched): now=matched.pop() if next_is_BL==True: print('Blue '+str(now)); print('Red '+str(now)); next_is_BL=False else: print('Red '+str(now)); print('Blue '+str(now)); next_is_BL=True