import java.util.Scanner; public class Main_yukicoder24 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] abcd = new int[10]; int y = 0; for (int i = 0; i < n; i++) { int[] tmp = new int[4]; for (int j = 0; j < 4; j++) { tmp[j] = sc.nextInt(); } int d; if (sc.next().equals("YES")) { d = 1; y++; } else { d = -1; } for (int j = 0; j < 4; j++) { abcd[tmp[j]] += d; } } for (int i = 0; i < 10; i++) { if (y == abcd[i]) { System.out.println(i); } } sc.close(); } }