import java.io.*; import java.util.*; class Main24 { public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] check = new int[10]; int ans = -1, max = -1; for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" "); for (int j = 0; j < line.length - 1; j++) { int m = Integer.parseInt(line[j]); if (line[4].equals("YES")) check[m]++; else check[m] = -1; } } for (int i = 0; i < check.length; i++) { if (max < check[i]) { max = check[i]; ans = i; } } System.out.println(ans); } }