t = int(input()) color = ["Red", "Blue"] for _ in range(t): n, m = map(int, input().split()) a = set(list(map(int, input().split()))) b = set(list(map(int, input().split()))) xs = a & b if len(a) > 0 and len(b) > 0 and len(xs) == 0: print("No") continue a -= xs b -= xs xs = list(xs) print("Yes") for x in b: print(f"{color[1]} {x}") if len(xs) > 0: x = xs.pop() print(f"{color[1]} {x}") print(f"{color[0]} {x}") for x in a: print(f"{color[0]} {x}") for i in range(len(xs)): print(f"{color[i % 2]} {xs[i]}") print(f"{color[1 - i % 2]} {xs[i]}")