#include using namespace std; using ll = long long; using ull = unsigned long long; #define v(t) vector #define p(t) pair #define p2(t, s) pair #define vp(t) v(p(t)) #define rep(i, n) for (int i=0,i##_len=((int)(n)); i=0; --i) #define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i) #define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr) #define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define RSORT(x) sort(rall(x)); #define pb push_back #define eb emplace_back #define INF (1e9) #define LINF (1e18) #define PI (acos(-1)) #define EPS (1e-7) #define DEPS (1e-10) // 解説読んで提出したい(やりかけ) int n, rnum, bnum; v(int) ans, cnt; v(v(int)) rb; v(p(p(int))) xy; bool dfs(int r, int b) { if (r+b == n) return true; if (r < rnum) { int rid = rb[0][r]; if (cnt[0] == xy[rid].first.first) { ans[r+b] = xy[rid].second.second + 1; cnt[xy[rid].first.second]++; if (dfs(r+1, b)) return true; cnt[xy[rid].first.second]--; ans[r+b] = 0; } } if (b < bnum) { int bid = rb[1][b]; if (cnt[1] == xy[bid].first.first) { ans[r+b] = xy[bid].second.second + 1; cnt[(1+xy[bid].first.second)%2]++; if (dfs(r, b+1)) return true; cnt[(1+xy[bid].first.second)%2]--; ans[r+b] = 0; } } return false; } int main(){ cin >> n; xy = v(p(p(int)))(n); rep(i, n) { char ci, xi; cin >> ci >> xi >> xy[i].first.first; xy[i].first.second = ((ci==xi)?0:-1); xy[i].second.first = ((xi=='R')?0:1); xy[i].second.second = i; } VSORT(xy); rep(i, n) xy[i].first.second *= -1; rb = v(v(int))(2); rep(i, n) rb[xy[i].second.first].pb(i); rnum = sz(rb[0]); bnum = sz(rb[1]); ans = v(int)(n); cnt = v(int)(2); if (dfs(0, 0)) { cout << "Yes" << endl; rep(i, n) printf("%d%c", ans[i], (i