#include using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=300000000; ll mod=998244353; int main(){ ll t; cin >> t; for (ll o = 0; o < t; o++) { ll n,m; cin >> n >> m; vectora(n),b(m); mapmemo; for (ll i = 0; i < n; i++) { cin >> a[i]; memo[a[i]]+=1; } mapmm; vectoraa(n,0),bb(m,0); ll now=0; for (ll i = 0; i < m; i++) { cin >> b[i]; if (memo[b[i]]>=1) { now++; bb.push_back(i); memo[b[i]]--; mm[b[i]]+=1; bb[i]=1; } } if (n==0) { cout << "Yes" << endl; for (ll i = 0; i < m; i++) { cout << "Blue " << b[i] << endl; } continue; } if (m==0) { cout << "Yes" << endl; for (ll i = 0; i < n; i++) { cout << "Red " << a[i] << endl; } continue; } for (ll i = 0; i < n; i++) { if (mm[a[i]]>=1) { mm[a[i]]--; aa[i]=1; } } if (now==0) { cout << "No" << endl; continue; } if (now%2) { cout << "Yes" << endl; for (ll i = 0; i < n; i++) { if (aa[i]==0) { cout << "Red " << a[i] << endl; } } ll x=0; for (ll i = 0; i < n; i++) { if (aa[i]==1) { if (x%2==0) { cout << "Red " << a[i]<< endl; cout << "Blue " << a[i] << endl; }else{ cout << "Blue " << a[i] << endl; cout << "Red " << a[i]<< endl; } x++; } } for (ll i = 0; i < m; i++) { if (bb[i]==0) { cout << "Blue " << b[i] << endl; } } }else{ cout << "Yes" << endl; ll saisyo=inf; for (ll i = 0; i < n; i++) { if (aa[i]==0) { cout << "Red " << a[i] << endl; }else{ saisyo=min(saisyo,i); } } cout << "Red " << a[saisyo] << endl; cout << "Blue " << a[saisyo] << endl; ll x=1; for (ll i = 0; i < m; i++) { if (bb[i]==0) { cout << "Blue " << b[i] << endl; } } for (ll i = 0; i < n; i++) { if (aa[i]==1&&i!=saisyo) { if (x%2==0) { cout << "Red " << a[i]<< endl; cout << "Blue " << a[i] << endl; }else{ cout << "Blue " << a[i] << endl; cout << "Red " << a[i]<< endl; } x++; } } } } }