// #define _GLIBCXX_DEBUG #include using namespace std; #include using namespace atcoder; using ll = long long; #define rep(i,n) for (ll i = 0; i < (n); ++i) using vl = vector; using vvl = vector; using P = pair; #define pb push_back #define int long long #define double long double #define INF (ll) 3e18 // Ctrl + Shift + B コンパイル // Ctrl + C 中断 // ./m 実行 void solve(){ int n, m; cin >> n >> m; map mp; rep(i, n) { int x; cin >> x; mp[x] += 1; } rep(i,m) { int x; cin >> x; mp[x] += 2; } if (n == 0 || m == 0){ cout << "Yes" << endl; for(auto [x, ab] : mp){ if (ab & 1) cout << "Red " << x << endl; if (ab & 2) cout << "Blue " << x << endl; } return; } vl three; for(auto [x, ab] : mp) if (ab == 3) three.push_back(x); if (!three.size()) {cout << "No" << endl; return;} cout << "Yes" << endl; for(auto [x, ab] : mp){ if (ab == 1) cout << "Red " << x << endl; } cout << "Red " << three[0] << endl; cout << "Blue " << three[0] << endl; for(auto [x, ab] : mp){ if (ab == 2) cout << "Blue " << x << endl; } int c = 1; auto teban = [&]() -> string { if (c) return "Blue "; else return "Red "; }; for(int i = 1; i < three.size(); i++){ cout << teban() << three[i] << endl; c ^= 1; cout << teban() << three[i] << endl; } } signed main(){ int t; cin >> t; rep(_,t){ solve(); } }