import java.util.Arrays; import java.util.Scanner; public class no24 { public static void main(String[] args) { boolean[] b = new boolean[10]; Arrays.fill(b, true); Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); for (int i = 0; i < N; i++) { int[] input = {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()}; if (sc.next().equals("NO")) { for (int j : input) { b[j] = false; } } else { for (int j = 0; j < 10; j++) { boolean bb = true; for (int k : input) { if (j == k) { bb = false; break; } } if (bb) { b[j] = false; } } } } for (int i = 0; i < 10; i++) { if (b[i]) { System.out.println(i); } } } }