import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); int[] flag = new int[10]; try { int count = Integer.parseInt(buff.readLine()); for (; count > 0; --count) { String[] box = buff.readLine().split(" "); int[] num = new int[4]; for (int i = 0; i < 4; ++i) { num[i] = Integer.parseInt(box[i]); } int add = -1; if (box[4].equals("YES")) { add = 1; } for (int i = 0; i < 4; ++i) { flag[num[i]] += add; } } int max = -10; for (int i = 0; i < 10; ++i) { if (max < flag[i]) { max = flag[i]; } } for (int i = 0; i < 10; ++i) { if (flag[i] == max) { System.out.println(i); break; } } } catch (NumberFormatException e) { } catch (IOException e) { } } }