#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(){ int n; cin>>n; vector C(n+1),X(n+1); vector Y(n+1); rep(i,n) cin>>C[i+1]>>X[i+1]>>Y[i+1]; vector> RR,BB,RB,BR; for(int i=1;i<=n;i++){ if(C[i]=='R' && X[i]=='R') RR.push_back({Y[i],i}); if(C[i]=='R' && X[i]=='B') RB.push_back({Y[i],i}); if(C[i]=='B' && X[i]=='R') BR.push_back({Y[i],i}); if(C[i]=='B' && X[i]=='B') BB.push_back({Y[i],i}); } sort(ALL(RR)); sort(ALL(RB)); sort(ALL(BR)); sort(ALL(BB)); queue> qrr,qrb,qbr,qbb; for(auto x:RR) qrr.push(x); for(auto x:RB) qrb.push(x); for(auto x:BR) qbr.push(x); for(auto x:BB) qbb.push(x); bool flag=true; int tmp=-1; for(auto x:RR){ if(x.first==tmp) flag=false; tmp=x.first; } tmp=-1; for(auto x:BB){ if(x.first==tmp) flag=false; tmp=x.first; } if(flag==false){ cout<<"No"< B; while(!qrr.empty() || !qbb.empty() || !qrb.empty() || !qbr.empty()){ if(!qrr.empty() && qrr.front().first==r){ if(qbr.empty() || qbr.front().first>=r+1){ auto x=qrr.front(); qrr.pop(); B.push_back(x.second); r++; continue; } } if(!qbb.empty() && qbb.front().first==b){ if(qrb.empty() || qrb.front().first>=b+1){ auto x=qbb.front(); qbb.pop(); B.push_back(x.second); b++; continue; } } if(!qrb.empty() || qrb.front().first==b){ if((qrr.empty() && qbr.empty()) || (qrr.empty() && qbr.front().first>=r+1) || (qbr.empty() && qrr.front().first>=r+1) || (qbr.front().first>=r+1 && qrr.front().first>=r+1)){ auto x=qrb.front(); qrb.pop(); B.push_back(x.second); r++; continue; } } if(!qbr.empty() || qbr.front().first==r){ if((qbb.empty() && qrb.empty()) || (qbb.empty() && qrb.front().first>=b+1) || (qrb.empty() && qbb.front().first>=b+1) || (qrb.front().first>=b+1 && qbb.front().first>=b+1)){ auto x=qbr.front(); qbr.pop(); B.push_back(x.second); b++; continue; } } cout<<"No"<