#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; char c[200020], x[200020]; int y[200020]; vector ans; priority_queue, vector>, greater>> bb, br, rb, rr; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> c[i] >> x[i] >> y[i]; if (c[i] == 'B' && x[i] == 'B') { bb.push(make_pair(y[i], i + 1)); } if (c[i] == 'B' && x[i] == 'R') { br.push(make_pair(y[i], i + 1)); } if (c[i] == 'R' && x[i] == 'B') { rb.push(make_pair(y[i], i + 1)); } if (c[i] == 'R' && x[i] == 'R') { rr.push(make_pair(y[i], i + 1)); } } int b = 0, r = 0; while (!bb.empty()) { pair p = bb.top(); if (p.first == b) { ans.emplace_back(p.second); b++; bb.pop(); } else { if (p.first < b) { cout << "No" << endl; return 0; } else { while (p.first > b) { if (br.empty()) { cout << "No" << endl; return 0; } pair p1 = br.top(); if (p1.first == r) { ans.emplace_back(p1.second); b++; br.pop(); } else { if (p1.first < r) { cout << "No" << endl; return 0; } else { while (p1.first > r) { if (rr.empty()) { while (p1.first > r) { if (rb.empty()) { cout << "No" << endl; return 0; } pair p3 = rb.top(); if (p3.first == b) { ans.emplace_back(p3.second); r++; rb.pop(); } else { cout << "No" << endl; return 0; } } } else { pair p2 = rr.top(); if (p2.first == r) { ans.emplace_back(p2.second); r++; rr.pop(); } else { if (p2.first < r) { cout << "No" << endl; return 0; } else { while (p2.first > r) { if (rb.empty()) { cout << "No" << endl; return 0; } pair p3 = rb.top(); if (p3.first == b) { ans.emplace_back(p3.second); r++; rb.pop(); } else { cout << "No" << endl; return 0; } } } } } } } } } } } } while (!br.empty()) { pair p1 = br.top(); if (p1.first == r) { ans.emplace_back(p1.second); b++; br.pop(); } else { if (p1.first < r) { cout << "No" << endl; return 0; } else { while (p1.first > r) { if (rr.empty()) { while (p1.first > r) { if (rb.empty()) { cout << "No" << endl; return 0; } pair p3 = rb.top(); if (p3.first == b) { ans.emplace_back(p3.second); r++; rb.pop(); } else { cout << "No" << endl; return 0; } } } else { pair p2 = rr.top(); if (p2.first == r) { ans.emplace_back(p2.second); r++; rr.pop(); } else { if (p2.first < r) { cout << "No" << endl; return 0; } else { while (p2.first > r) { if (rb.empty()) { cout << "No" << endl; return 0; } pair p3 = rb.top(); if (p3.first == b) { ans.emplace_back(p3.second); r++; rb.pop(); } else { cout << "No" << endl; return 0; } } } } } } } } } while (!rr.empty()) { pair p2 = rr.top(); if (p2.first == r) { ans.emplace_back(p2.second); r++; rr.pop(); } else { if (p2.first < r) { cout << "No" << endl; return 0; } else { while (p2.first > r) { if (rb.empty()) { cout << "No" << endl; return 0; } pair p3 = rb.top(); if (p3.first == b) { ans.emplace_back(p3.second); r++; rb.pop(); } else { cout << "No" << endl; return 0; } } } } } while (!rb.empty()) { pair p3 = rb.top(); if (p3.first == b) { ans.emplace_back(p3.second); r++; rb.pop(); } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; for (int i = 0; i < n; i++) { cout << ans[i]; if (i != n - 1) { cout << " "; } } cout << endl; }