import java.io.*; import java.util.stream.*; // 処理 class Process { private PrintWriter printWriter; private int[][] A; private String[] R; Process(PrintWriter printWriter, int[][] A, String[] R) { this.printWriter = printWriter; this.A = A; this.R = R; } // 結果を出力 void printResult() throws IOException { int[] numCount = new int[10]; for(int i = 0; i < A.length; i++) { for(int j = 0; j < A[i].length; j++) { numCount[A[i][j]] = R[i].equals("YES") ? (numCount[A[i][j]] + 1) : (numCount[A[i][j]] - 1); } } int max = IntStream.of(numCount).max().getAsInt(); int index = 0; for(int i = 0; i < numCount.length; i++) { if(numCount[i] == max) { index = i; break; } } printWriter.println(index); } } public class Main { public static void main(String[] args) throws IOException { var bufferedReader = new BufferedReader(new InputStreamReader(System.in)); var printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); // 入力 int N = Integer.parseInt(bufferedReader.readLine().trim()); String[] input = new String[5]; int[][] A = new int[N][4]; String[] R = new String[N]; for(int n = 0; n < N; n++) { input = bufferedReader.readLine().trim().split("[ ]+"); for(int a = 0; a < A[n].length; a++) { A[n][a] = Integer.parseInt(input[a]); } R[n] = input[4]; } // Process クラスで処理を行う var process = new Process(printWriter, A, R); process.printResult(); // 各ストリームを閉じる // 出力ストリームを閉じるときに標準出力に文字を出力する bufferedReader.close(); printWriter.close(); } }