import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(reader.readLine()); int[] a = new int[10]; int maxDuplication = 0; for (int i = 0; i < N; i++) { String[] line = reader.readLine().split(" "); String answer = line[4]; if (answer.equals("YES")) { for (int j = 0; j < 10; j++) { for (int k = 0; k < 4; k++) { if (j == Integer.parseInt(line[k])) { a[j] = a[j] + 1; } } } maxDuplication += 1; } else { for (int j = 0; j < 10; j++) { for (int k = 0; k < 4; k++) { if (j == Integer.parseInt(line[k])) { a[j] = a[j] - 1; } } } } } for (int i = 0; i < 10; i++) { if (a[i] == maxDuplication) { System.out.println(i); } } } }