#include using namespace std; using ll = long long; void solve(){ int N, M; cin >> N >> M; vector A(N), B(M), ab, a, b; for(auto &v : A) cin >> v; for(auto &v : B) cin >> v; sort(A.begin(), A.end()); sort(B.begin(), B.end()); set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(ab, ab.end())); set_difference(A.begin(), A.end(), ab.begin(), ab.end(), inserter(a, a.end())); set_difference(B.begin(), B.end(), ab.begin(), ab.end(), inserter(b, b.end())); if(!a.empty() && !b.empty() && ab.empty()){ cout << "No" << '\n'; return; } if(!a.empty())a.back() = 1145141919; cout << "Yes" << '\n'; for(auto &v : a)cout << "Red " << v << '\n'; if(!ab.empty()){ cout << "Red " << ab[0] << '\n'; cout << "Blue " << ab[0] << '\n'; } for(auto &v : b)cout << "Blue " << v << '\n'; for(int i = 1; i < ab.size(); i++){ if(i & 1){ cout << "Blue " << ab[i] << '\n'; cout << "Red " << ab[i] << '\n'; }else{ cout << "Red " << ab[i] << '\n'; cout << "Blue " << ab[i] << '\n'; } } } int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--) solve(); }