#include using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const string colors = "RB"; int colorid(char c){ return colors.find(c); } struct Ball{ int c,x,y,i; }; struct BallCmp{ int c; bool operator()(const Ball& l,const Ball& r)const{ if(l.y!=r.y) return l.y (r.c^c); } }; struct graph{ int N; vector> E; graph(int n){ N=n; E.resize(N); } void add_edge(int u,int v){ E[u].push_back(v); } vector topological(){ vector I(N); rep(u,N) for(int v:E[u]) I[v]++; queue Q; rep(i,N) if(I[i]==0) Q.push(i); vector res; while(Q.size()){ int q=Q.front(); Q.pop(); res.push_back(q); for(int e:E[q]){ I[e]--; if(I[e]==0) Q.push(e); } } if(res.size()!=N) return vector(); return move(res); } }; int main(){ int N; cin>>N; vector D[2]; rep(i,N){ char c,x; int y; cin>>c>>x>>y; D[colorid(x)].push_back({colorid(c),colorid(x),y,i}); } rep(i,2) sort(D[i].begin(),D[i].end(),BallCmp{i}); graph G(N); rep(i,2) rep(j,(int)D[i].size()-1) G.add_edge(D[i][j].i,D[i][j+1].i); vector P[2][2]; rep(i,2) for(Ball& b:D[i]) P[i][b.c].push_back(b.i); rep(x,2){ int p=0; auto& tg = P[x^1][x]; for(Ball& b:D[x]){ if(p>b.y || b.y-p>tg.size()){ cout<<"No"<=0) G.add_edge(tg[b.y-p-1],b.i); if(b.y-p