#include using namespace std; using lint = long long; using pint = pair; using plint = pair; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } void bad() { puts("No"); exit(0); } int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; cin >> N; vector C(N), X(N), Y(N); REP(i, N) { char c, x; cin >> c >> x >> Y[i]; C[i] = (c == 'B'); X[i] = (x == 'B'); } const int nb = accumulate(C.begin(), C.end(), 0); vector blue(nb, -1); vector red(N - nb, -1); vector pending_reds; vector pending_blues; REP(i, N) { if (C[i] == 0) { if (X[i]) pending_reds.emplace_back(Y[i], i); else { if (Y[i] >= int(red.size()) or red[Y[i]] != -1) bad(); red[Y[i]] = i; } } else { if (X[i]) { if (Y[i] >= int(blue.size()) or blue[Y[i]] != -1) bad(); blue[Y[i]] = i; } else pending_blues.emplace_back(Y[i], i); } } sort(pending_reds.begin(), pending_reds.end()); sort(pending_blues.begin(), pending_blues.end()); { int cur = 0; for (auto [sz, i] : pending_blues) { while (blue[cur] >= 0) cur++; blue[cur] = i; cur++; } } { int cur = 0; for (auto [sz, i] : pending_reds) { while (red[cur] >= 0) cur++; red[cur] = i; cur++; } } vector lo(red.size(), -1), hi(red.size(), blue.size() - 1); REP(t, blue.size()) { int i = blue[t]; if (X[i] == 0) { if (Y[i] > red.size()) bad(); if (Y[i]) chmin(hi[Y[i] - 1], t - 1); if (Y[i] < lo.size()) chmax(lo[Y[i]], t); } } REP(t, red.size()) { int i = red[t]; if (X[i] == 1) { lo[t] = hi[t] = Y[i] - 1; } } REP(i, red.size() - 1) chmax(lo[i + 1], lo[i]); IREP(i, red.size() - 1) chmin(hi[i], hi[i + 1]); REP(i, red.size()) if (lo[i] > hi[i]) bad(); vector ret; int ib = 0, ir = 0; auto add = [&](int i) { if (X[i] == 1) { if (ib != Y[i]) bad(); } else { if (ir != Y[i]) bad(); } (C[i] ? ib : ir)++; ret.emplace_back(i); }; int cur = 0; int now = -1; while (now < int(blue.size())) { while (cur < red.size() and lo[cur] == now) add(red[cur]), cur++; now++; if (now >= int(blue.size())) break; add(blue[now]); } cout << "Yes\n"; REP(i, N) cout << ret[i] + 1 << (i + 1 == N ? '\n' : ' '); }