for _ in range(int(input())): n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) sa = set(a) sb = set(b) flg = 1 for v in sa: if v in sb: flg = 0 break if flg: if n or m: for v in a: print("Red", v) for v in b: print("Blue", v) continue print("No") continue print("Yes") a1 = [] a2 = [] for v in a: if v in sb: a1.append(v) else: a2.append(v) b1 = [] b2 = [] for v in b: if v in sa: b1.append(v) else: b2.append(v) a1.sort() for v in a2: print("Red", v) x = a1.pop() print("Red", x) print("Blue", x) for v in b2: print("Blue", v) flg = 1 for v in a1: if flg: print("Blue", v) print("Red", v) else: print("Red", v) print("Blue", v) flg ^= 1