#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
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<int,int> m,m1,m2,m3;
    vector<int> A(3);
    vector<vector<int>> 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<int> 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"<<endl;
    else if(A[2]==0 && c1) cout<<"YES"<<endl;
    else if(A[2]==0) cout<<"NO"<<endl;
    else if(c2>=2 || (c1>=1 && c2==1)) cout<<"YES"<<endl;
    else if(c2==0 && c1<=1) cout<<"NO"<<endl;
    else if(c2==1 && A[2]>=2) cout<<"NO"<<endl;
    else if(c2==1) cout<<"YES"<<endl;
    else{
      bool b=true;
      rep(j,3){
        bool f=false;
        rep(l,G[j].size()){
          if(s.count(G[j][l])) f=true;
        }
        if(f==false) b=false;
      }
      if(b) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    } 
  }

  return 0;
}