import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); PrintWriter pw = new PrintWriter(System.out); for (int z = 0; z < t; z++) { String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); int[] a = new int[n]; Set seta = new HashSet<>(); for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); seta.add(a[i]); } sa = br.readLine().split(" "); int[] b = new int[m]; Set setb = new HashSet<>(); for (int i = 0; i < m; i++) { b[i] = Integer.parseInt(sa[i]); setb.add(b[i]); } seta.retainAll(setb); if (seta.isEmpty()) { if (n == 0 || m == 0) { pw.println("Yes"); if (n == 0) { for (int i = 0; i < m; i++) { pw.println("Blue " + b[i]); } } else { for (int i = 0; i < n; i++) { pw.println("Red " + a[i]); } } } else { pw.println("No"); } } else { pw.println("Yes"); if (seta.size() % 2 == 0 && seta.size() != n && seta.size() != m) { Integer e = seta.iterator().next(); seta.remove(e); } if (seta.size() < n) { for (int i = 0; i < n; i++) { if (!seta.contains(a[i])) { pw.println("Red " + a[i]); } } Integer[] arr = seta.toArray(new Integer[0]); for (int i = 0; i < arr.length; i++) { if (i % 2 == 0) { pw.println("Red " + arr[i]); pw.println("Blue " + arr[i]); } else { pw.println("Blue " + arr[i]); pw.println("Red " + arr[i]); } } for (int i = 0; i < m; i++) { if (!seta.contains(b[i])) { pw.println("Blue " + b[i]); } } } else { for (int i = 0; i < m; i++) { if (!seta.contains(b[i])) { pw.println("Blue " + b[i]); } } Integer[] arr = seta.toArray(new Integer[0]); for (int i = 0; i < arr.length; i++) { if (i % 2 == 0) { pw.println("Blue " + arr[i]); pw.println("Red " + arr[i]); } else { pw.println("Red " + arr[i]); pw.println("Blue " + arr[i]); } } for (int i = 0; i < n; i++) { if (!seta.contains(a[i])) { pw.println("Red " + a[i]); } } } } } pw.flush(); br.close(); } }