#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; void solve() { int N, M; cin >> N >> M; set r, b, c, d, e; for (int i = 1; i <= N; i++) { int x; cin >> x; r.insert(x); } for (int i = 1; i <= M; i++) { int x; cin >> x; b.insert(x); } set_intersection(r.begin(), r.end(), b.begin(), b.end(), inserter(c, c.end())); set_difference(r.begin(), r.end(), c.begin(), c.end(), inserter(d, d.end())); set_difference(b.begin(), b.end(), c.begin(), c.end(), inserter(e, e.end())); if (c.size() == 0 && (d.size() > 0 && e.size() > 0)) { cout << "No" << endl; return; } cout << "Yes" << endl; for (auto x: d) { cout << "Red " << x << endl; } if (c.size() > 0) { cout << "Red " << *c.begin() << endl; cout << "Blue " << *c.begin() << endl; c.erase(*c.begin()); } for (auto x: e) { cout << "Blue " << x << endl; } int pos = 0; for (auto x: c) { if (pos % 2 == 0) { cout << "Blue " << x << endl; cout << "Red " << x << endl; } else { cout << "Red " << x << endl; cout << "Blue " << x << endl; } pos++; } } int main() { int T; cin >> T; while (T--) solve(); return 0; }