#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int tra(char c) { return c == 'R' ? 0 : 1; } int main() { int n; cin >> n; vector ball(2, vector(n + 1, vector{})); vector c(n); REP(i, n) { char ci, x; int y; cin >> ci >> x >> y; c[i] = tra(ci); ball[tra(x)][y].emplace_back(i); } REP(j, n) { sort(ALL(ball[0][j]), [&](int a, int b) { return c[a] < c[b]; }); if (ball[0][j].size() >= 2 && ball[0][j][0] == 0 && ball[0][j][0] == ball[0][j][1]) { cout << "No\n"; return 0; } } REP(j, n) { sort(ALL(ball[1][j]), [&](int a, int b) { return c[a] > c[b]; }); if (ball[1][j].size() >= 2 && ball[1][j][0] == 1 && ball[1][j][0] == ball[1][j][1]) { cout << "No\n"; return 0; } } int p[2] = {}; vector ans; while (ans.size() < n) { if (ball[0][p[0]].empty() && ball[1][p[1]].empty()) { cout << "No\n"; return 0; } if (ball[0][p[0]].empty()) { int id = ball[1][p[1]].back(); ball[1][p[1]].pop_back(); ans.emplace_back(id); ++p[c[id]]; } else if (ball[1][p[1]].empty()) { int id = ball[0][p[0]].back(); ball[0][p[0]].pop_back(); ans.emplace_back(id); ++p[c[id]]; } else if (c[ball[0][p[0]].back()] == 1 && c[ball[1][p[1]].back()] == 0) { cout << "No\n"; return 0; } else if (c[ball[0][p[0]].back()] == 0) { int id = ball[0][p[0]].back(); ball[0][p[0]].pop_back(); ans.emplace_back(id); ++p[c[id]]; } else { int id = ball[1][p[1]].back(); ball[1][p[1]].pop_back(); ans.emplace_back(id); ++p[c[id]]; } } cout << "Yes\n"; REP(i, n) cout << ans[i] + 1 << " \n"[i + 1 == n]; return 0; }