using System; using System.Collections.Generic; using System.Linq; class Y { static void Main() { var n = int.Parse(Console.ReadLine()); var cxys = new bool[n] .Select((_, i) => { var v = Console.ReadLine().Split(); return (i: i + 1, c: v[0], x: v[1], y: int.Parse(v[2])); }) .ToArray(); var qr = new Queue<(int i, string c, string x, int y)>(cxys.Where(v => v.x == "R").OrderBy(v => v.y).ThenBy(v => v.c)); var qb = new Queue<(int i, string c, string x, int y)>(cxys.Where(v => v.x == "B").OrderBy(v => v.y).ThenByDescending(v => v.c)); var a = new List(); var d = new Dictionary(); d["R"] = 0; d["B"] = 0; while (qr.Count > 0 || qb.Count > 0) { if (qr.Count == 0) { var v = qb.Dequeue(); if (d[v.x] != v.y) { Console.WriteLine("No"); return; } a.Add(v.i); d[v.c]++; } else if (qb.Count == 0) { var v = qr.Dequeue(); if (d[v.x] != v.y) { Console.WriteLine("No"); return; } a.Add(v.i); d[v.c]++; } else { var vr = qr.Peek(); var vb = qb.Peek(); if (d[vr.x] != vr.y && d[vb.x] != vb.y) { Console.WriteLine("No"); return; } if (d[vr.x] != vr.y) { qb.Dequeue(); a.Add(vb.i); d[vb.c]++; } else if (d[vb.x] != vb.y) { qr.Dequeue(); a.Add(vr.i); d[vr.c]++; } else { if (vr.c == vr.x && vb.c == vb.x || vr.c != vr.x && vb.c != vb.x) { qr.Dequeue(); a.Add(vr.i); d[vr.c]++; } else { if (vr.c == vr.x) { qr.Dequeue(); a.Add(vr.i); d[vr.c]++; } else { qb.Dequeue(); a.Add(vb.i); d[vb.c]++; } } } } } Console.WriteLine("Yes\n" + string.Join(" ", a)); } }