import sys input = sys.stdin.readline def main(): T = int(input()) for _ in range(T): N, M = map(int, input().split()) A = set(map(int, input().split())) B = set(map(int, input().split())) pair = [] ans = [] while A: n = A.pop() if n in B: pair.append(n) B.discard(n) else: ans.append(f'Red {n}') if not pair: if M == 0: print('Yes') print(*ans, sep='\n') elif N == 0: print('Yes') while B: print(f'Blue {B.pop()}') else: print('No') continue n = pair.pop() ans.append(f'Red {n}') ans.append(f'Blue {n}') while B: ans.append(f'Blue {B.pop()}') cur = 'Blue' while pair: n = pair.pop() if cur == 'Blue': ans.append(f'Blue {n}') ans.append(f'Red {n}') cur = 'Red' else: ans.append(f'Red {n}') ans.append(f'Blue {n}') cur = 'Blue' print('Yes') print(*ans, sep='\n') main()