#include using namespace std; using VI = vector; #define FOR(i,a,n) for(int i=(a);i<(n);++i) #define fSORT(a,f) sort(a.begin(),a.end(),f) #define tp(a,i) get(a) inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } templateinline void print(const T& a) { cout << a << "\n"; } templateinline void print(const vector& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); } int main() { init(); int n; cin >> n; vector> wf_red, wf_blue; FOR(i, 0, n) { char c, x; int y; cin >> c >> x >> y; if (x == 'R')wf_red.emplace_back(c, y, i); else wf_blue.emplace_back(c, y, i); } fSORT(wf_red, [](auto a, auto b) {if (tp(a, 1) == tp(b, 1))return tp(a, 0) < tp(b, 0); return tp(a, 1) < tp(b, 1); }); fSORT(wf_blue, [](auto a, auto b) {if (tp(a, 1) == tp(b, 1))return tp(a, 0) > tp(b, 0); return tp(a, 1) < tp(b, 1); }); VI ans; ans.reserve(n); tuple unit('?', 1000000, -1); for (int r = 0, b = 0, r_idx = 0, b_idx = 0; r_idx < wf_red.size() || b_idx < wf_blue.size();) { auto [rc, ry, rnum] = (r_idx == wf_red.size() ? unit : wf_red[r_idx]); auto [bc, by, bnum] = (b_idx == wf_blue.size() ? unit : wf_blue[b_idx]); if (ry == r && b + (rc == 'B') <= by) { ++r_idx; ans.emplace_back(rnum + 1); if (rc == 'R')++r; else ++b; continue; } if (by == b && r + (bc == 'R') <= ry) { ++b_idx; ans.emplace_back(bnum + 1); if (bc == 'R')++r; else ++b; continue; } print("No"); return 0; } print("Yes"); print(ans); return 0; }