#include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000000 struct Ball{ char color,ncolor; int ncnt; int ind; }; deque red,blue; deque ret; map mp; void NG(){ cout<<"No"<>N; vector Y(N); vector C(N),X(N); rep(i,N){ cin>>C[i]>>X[i]>>Y[i]; } deque B,R; rep(i,N){ if(C[i]=='B')B.push_back(-1); else R.push_back(-1); } rep(i,N){ if(C[i]==X[i]){ int t = Y[i]; if(C[i]=='R')swap(B,R); if(t>=B.size())NG(); if(B[t]!=-1)NG(); B[t] = i; if(C[i]=='R')swap(B,R); } } vector> pB,pR; rep(i,N){ if(C[i]==X[i])continue; if(C[i]=='B')pB.emplace_back(Y[i],i); else pR.emplace_back(Y[i],i); } sort(pB.begin(),pB.end()); sort(pR.begin(),pR.end()); int now = 0; rep(i,pB.size()){ while(B[now]!=-1)now++; B[now] = pB[i].second; } now = 0; rep(i,pR.size()){ while(R[now]!=-1)now++; R[now] = pR[i].second; } rep(i,B.size()){ blue.push_back({'B',X[B[i]],Y[B[i]],B[i]}); } rep(i,R.size()){ red.push_back({'R',X[R[i]],Y[R[i]],R[i]}); } // blue = B,red = R; solve(); NG(); return 0; }