#include using namespace std; bool isok(const vector>> &q, const vector &idx, int r, int b) { for (int i = 0; i < 4; i++) { int color = i % 2 == 0 ? r : b; if (idx[i] > int(q.at(i).size())) return false; if (idx[i] < int(q.at(i).size()) and q.at(i).at(idx[i]).first < color) return false; } return true; }; void dfs(const vector>> &q, vector v, vector &ans, int n) { if (int(ans.size()) == n) return; for (int i = 0; i < 4; i++) { if (int(q.at(i).size()) == v.at(i)) continue; int r = v.at(0) + v.at(1), b = v.at(2) + v.at(3); if (i % 2 == 0) { if (q.at(i).at(v.at(i)).first != r) continue; } else { if (q.at(i).at(v.at(i)).first != b) continue; } v.at(i)++; r = v.at(0) + v.at(1); b = v.at(2) + v.at(3); if (isok(q, v, r, b)) { ans.push_back(q.at(i).at(v.at(i) - 1).second); dfs(q, v, ans, n); if (int(ans.size()) == n) return; ans.pop_back(); } v.at(i)--; } } int main() { int n; cin >> n; vector c(n), x(n); vector y(n); for (int i = 0; i < n; i++) { cin >> c.at(i) >> x.at(i) >> y.at(i); } vector>> q(4); for (int i = 0; i < n; i++) { if (c.at(i) == 'R') { if (x.at(i) == 'R') { q.at(0).emplace_back(y.at(i), i); } else { q.at(1).emplace_back(y.at(i), i); } } else { if (x.at(i) == 'R') { q.at(2).emplace_back(y.at(i), i); } else { q.at(3).emplace_back(y.at(i), i); } } } for (int i = 0; i < 4; i++) { sort(q.at(i).begin(), q.at(i).end()); } vector ans; dfs(q, vector{0, 0, 0, 0}, ans, n); if (ans.empty()) { cout << "No" << endl; return 0; } cout << "Yes" << endl; for (int i = 0; i < n; i++) { cout << ans.at(i) + 1; if (i == n - 1) { cout << endl; } else { cout << " "; } } }