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(" "); long[] a = new long[n]; Set seta = new HashSet<>(); for (int i = 0; i < n; i++) { a[i] = Long.parseLong(sa[i]); seta.add(a[i]); } sa = br.readLine().split(" "); long[] b = new long[m]; Set setb = new HashSet<>(); for (int i = 0; i < m; i++) { b[i] = Long.parseLong(sa[i]); setb.add(b[i]); } for (int i = 0; i < n; i++) { if (!setb.contains(a[i])) { seta.remove(a[i]); } } 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"); for (int i = 0; i < n; i++) { if (!seta.contains(a[i])) { pw.println("Red " + a[i]); } } Long[] arr = seta.toArray(new Long[0]); pw.println("Red " + arr[0]); pw.println("Blue " + arr[0]); for (int i = 0; i < m; i++) { if (!seta.contains(b[i])) { pw.println("Blue " + b[i]); } } for (int i = 1; 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]); } } } } pw.flush(); br.close(); } }