#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin>>t; while(t--){ int n; cin>>n; map m,m1,m2,m3; vector A(3); vector> G(3); rep(i,n){ char c; int d; cin>>c>>d; if(c=='R') A[0]++,G[0].push_back(d); else if(c=='G') A[1]++,G[1].push_back(d); else A[2]++,G[2].push_back(d); m[d]++; } sort(ALL(A)); reverse(ALL(A)); int c1=0,c2=0; set s; for(auto [a,b]:m){ if(b==2) c1++; else if(b==3) c2++; if(b>=2) s.insert(a); } if(A[1]==0) cout<<"YES"<=2 || (c1>=1 && c2==1)) cout<<"YES"<=2) cout<<"NO"<