#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair P; int main() { int n; cin>>n; char c[200020], x[200020]; int y[200020]; vector vr, vb; map mp; for(int i=0; i>c[i]>>x[i]>>y[i]; if(c[i]==x[i]){ mp[{x[i], y[i]}]++; } if(x[i]=='R') vr.push_back(i); else vb.push_back(i); } sort(vr.begin(), vr.end(), [&](int i, int j){ if(y[i]!=y[j]) return y[i]1){ cout<<"No"< ans; int cr=0, cb=0; for(int i=0; icr && y[q]>cb){ cout<<"No"<cr){ vb.pop_back(); ans.push_back(q); if(c[q]=='R') cr++; else cb++; }else if(y[q]>cb){ vr.pop_back(); ans.push_back(p); if(c[p]=='R') cr++; else cb++; }else{ if(x[p]==c[p]){ vr.pop_back(); ans.push_back(p); if(c[p]=='R') cr++; else cb++; }else if(x[q]==c[q]){ vb.pop_back(); ans.push_back(q); if(c[p]=='R') cr++; else cb++; cb++; }else{ cout<<"No"<