#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; const double PI=acos(-1); void solve(){ int N; cin>>N; set rst,bst,gst; int match=0; for(int i=0;i>c>>d; if(c=='R'){ rst.insert(d); match|=(1<<0); }else if(c=='G'){ gst.insert(d); match|=(1<<1); }else if(c=='B'){ bst.insert(d); match|=(1<<2); } } if(__builtin_popcount(match)==1){ //1色しかない cout<<"YES"< cnt(N+1,0); for(int v:rst){ cnt[v]|=(1<<0); } for(int v:gst){ cnt[v]|=(1<<1); } for(int v:bst){ cnt[v]|=(1<<2); } int S=0; bool flag=false; for(int i=1;i<=N;i++){ if(__builtin_popcount(cnt[i])<=1) continue;//bitが一つ以下しかたっていない S|=cnt[i]; } if(S==match){ cout<<"YES"<>T; for(int t=0;t