import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } int readColor() { const input = readToken; return (input == "R") ? 0 : 1; } int N; int[] C, X, Y; int[] solve() { alias Entry = Tuple!(int, "y", int, "u"); auto esss = new Entry[][][](2, 2); foreach (u; 0 .. N) { esss[C[u]][X[u]] ~= Entry(Y[u], u); } foreach (c; 0 .. 2) { foreach (x; 0 .. 2) { esss[c][x].sort; } } debug { foreach (c; 0 .. 2) { foreach (x; 0 .. 2) { writefln("esss[%s][%s] = %s", c, x, esss[c][x]); } } } auto lens = new int[2]; foreach (c; 0 .. 2) { foreach (x; 0 .. 2) { lens[c] += cast(int)(esss[c][x].length); } } auto uss = new int[][2]; foreach (c; 0 .. 2) { uss[c] = new int[lens[c]]; uss[c][] = -1; foreach (ref e; esss[c][c]) { if (!(0 <= e.y && e.y < lens[c])) { return null; } if (uss[c][e.y] != -1) { return null; } uss[c][e.y] = e.u; } int pos; foreach (ref e; esss[c][c ^ 1]) { for (; uss[c][pos] != -1; ++pos) {} uss[c][pos] = e.u; } } debug { writeln("uss = ", uss); } auto mns = new int[lens[1]]; auto mxs = new int[lens[1]]; mns[] = 0; mxs[] = lens[0]; foreach (i0; 0 .. lens[0]) { const u = uss[0][i0]; if (X[u] == 1) { if (!(0 <= Y[u] && Y[u] <= lens[1])) { return null; } if (Y[u] - 1 >= 0) { chmin(mxs[Y[u] - 1], i0); } if (Y[u] < lens[1]) { chmax(mns[Y[u]], i0 + 1); } } } foreach (i1; 0 .. lens[1]) { const u = uss[1][i1]; if (X[u] == 0) { if (!(0 <= Y[u] && Y[u] <= lens[0])) { return null; } chmax(mns[i1], Y[u]); chmin(mxs[i1], Y[u]); } } auto vals = new int[lens[1]]; int bef = 0; foreach (i1; 0 .. lens[1]) { chmax(bef, mns[i1]); if (!(bef <= mxs[i1])) { return null; } vals[i1] = bef; } vals ~= lens[0]; debug { writeln("vals = ", vals); } int[] ans; { int i0; foreach (i1; 0 .. lens[1] + 1) { for (; i0 < vals[i1]; ++i0) { ans ~= uss[0][i0]; } if (i1 < lens[1]) { ans ~= uss[1][i1]; } } } return ans; } void main() { try { for (; ; ) { N = readInt(); C = new int[N]; X = new int[N]; Y = new int[N]; foreach (u; 0 .. N) { C[u] = readColor(); X[u] = readColor(); Y[u] = readInt(); } const ans = solve; if (ans) { writeln("Yes"); foreach (j; 0 .. N) { if (j > 0) write(" "); write(ans[j] + 1); } writeln; } else { writeln("No"); } } } catch (EOFException e) { } }