import sys from functools import partial # import pypyjit # pypyjit.set_param('max_unroll_recursion = -1') sys.setrecursionlimit(500005) stdin = sys.stdin ns = lambda: stdin.readline().strip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nz = lambda: list(map(lambda x: int(x)-1, stdin.readline().split())) # 遅い printa = partial(print, sep="\n") # printa(*A) で各要素を改行して出力 mod = 1000000007 # 998244353 inf = 10 ** 18 T = ni() def solve(): N, M = na() A = set(na()) B = set(na()) C = A & B Red = A - C Blue = B - C if N and M and not C: print("No") return print("Yes") if Red: for r in Red: print("Red", r) if C: x = C.pop() print("Red", x) print("Blue", x) if Blue: for b in Blue: print("Blue", b) for c in C: print("Blue", c) print("Red", c) for i in range(T): solve()