#include using namespace std; #define rep(i, a, n) for(int i=(a); i<(n); ++i) #define per(i, a, n) for(int i=(a); i>(n); --i) #define pb emplace_back #define mp make_pair #define clr(a, b) memset(a, b, sizeof(a)) #define all(x) (x).begin(),(x).end() #define lowbit(x) (x & -x) #define fi first #define se second #define lson o<<1 #define rson o<<1|1 #define gmid l[o]+r[o]>>1 using ll = long long; using ull = unsigned long long; using pii = pair; using pll = pair; using ui = unsigned int; constexpr int mod = 998244353; constexpr int inf = 0x3f3f3f3f; constexpr double EPS = 1e-8; const double PI = acos(-1.0); constexpr int N = 2e5 + 10; int T, n, m, a[N], b[N]; set st; vector> ans; bool ok(){ st.clear(); ans.clear(); rep(i, 1, n + 1) st.insert(a[i]); vector same, x; rep(i, 1, m + 1){ if(st.count(b[i])){ same.pb(b[i]); st.erase(b[i]); } else { x.pb(b[i]); } } if(n && m && !same.size()){ return 0; } if(!n){ rep(i, 1, m + 1) ans.pb("Blue", b[i]); return 1; } if(!m){ rep(i, 1, n + 1) ans.pb("Red", a[i]); return 1; } for(int v : st) ans.pb("Red", v); ans.pb("Red", same[0]); ans.pb("Blue", same[0]); for(int v : x) ans.pb("Blue", v); rep(i, 1, same.size()){ if(i & 1){ ans.pb("Blue", same[i]); ans.pb("Red", same[i]); } else { ans.pb("Red", same[i]); ans.pb("Blue", same[i]); } } return 1; } void _main(){ cin >> T; while(T--){ cin >> n >> m; rep(i, 1, n + 1){ cin >> a[i]; } rep(i, 1, m + 1){ cin >> b[i]; } if(ok()){ cout << "Yes\n"; for(auto [s, v] : ans){ cout << s << ' ' << v << '\n'; } } else { cout << "No\n"; } } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); _main(); return 0; }