T = int(input()) for _ in range(T): N,M = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) a = set(A) b = set(B) c = a & b if N == 0: print('Yes') for bb in B: print('Blue',bb) continue if M == 0: print('Yes') for aa in A: print('Red',aa) continue if len(c) == 0: print('No') continue print('Yes') for aa in A: if aa not in c: print('Red',aa) u = c.pop() print('Red',u) print('Blue',u) for bb in B: if bb not in c and bb != u: print('Blue',u) now = True while c: u = c.pop() if now: print("Blue",u) print("Red",u) else: print('Red',u) print('Blue',u) now = not now