#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[i].size())) return false; if (idx[i] < int(q[i].size()) and q[i][idx[i]].first < color) return false; } return true; }; void dfs(const vector>> &q, vector v, vector &ans, int n) { if (clock() >= 1800000) return; if (int(ans.size()) == n) return; for (int i = 3; i >= 0; i--) { if (int(q[i].size()) == v[i]) continue; int r = v[0] + v[1], b = v[2] + v[3]; if (i % 2 == 0) { if (q[i][v[i]].first != r) continue; } else { if (q[i][v[i]].first != b) continue; } v[i]++; r = v[0] + v[1]; b = v[2] + v[3]; if (isok(q, v, r, b)) { ans.push_back(q[i][v[i] - 1].second); dfs(q, v, ans, n); if (int(ans.size()) == n) return; ans.pop_back(); } v[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 (int(ans.size()) < n) { 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 << " "; } } }