import java.util.*; public class d { static short[] state, l, r; static List original, topoSort; public static void main(String[] args) { //Read input Scanner scan = new Scanner(System.in); long n = scan.nextLong(); short m = scan.nextShort(); state = new short[m+1]; l = new short[m+1]; r = new short[m+1]; for (int i = 1; i <= m; i++) { char inState = scan.next().charAt(0); if (inState == 'L') state[i] = 0; else if (inState == 'R') state[i] = 1; else System.out.println("ERRRRORRROR"); l[i] = scan.nextShort(); r[i] = scan.nextShort(); /*System.out.print(state[i]); System.out.print(l[i]); System.out.println(r[i]);*/ } //Topological sort original = new LinkedList(); for (short i=1; i <= m; i++) original.add(i); topoSort = new LinkedList(); while (!original.isEmpty()) { visit(original.get(0)); } //System.out.println(topoSort); //Calculate counts /*long[] counts = new long[m+1]; counts[1] = n; for (Short i : topoSort) { if (counts[i] % 2 == 0) { counts[l[i]] += counts[i] / 2; counts[r[i]] += counts[i] / 2; } else { if (state[i] == 0) { counts[l[i]] += counts[i] / 2 + 1; counts[r[i]] += counts[i] / 2; } else { counts[l[i]] += counts[i] / 2; counts[r[i]] += counts[i] / 2 + 1; } } } //Print answer for (int i = 1; i <= m; i++) { if ((state[i] + counts[i]) % 2 == 0) System.out.print("L"); else System.out.print("R"); } System.out.println();*/ } public static void visit(short i) { if (i == 0) return; if (!topoSort.contains(new Short(l[i]))) visit(l[i]); if (!topoSort.contains(new Short(r[i]))) visit(r[i]); Short toRemove = new Short(i); if (original.contains(toRemove)) original.remove(toRemove); topoSort.add(0, i); } }