import java.util.Arrays; import java.util.Scanner; public class Yukicoder24 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a, b, c, d, max = -100, index = 0; int[] num = new int[10]; Arrays.fill(num, 0); for (int i = 0; i < n; i++) { a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt(); if (sc.next().equals("NO")) { num[a] = -100; num[b] = -100; num[c] = -100; num[d] = -100; } else { num[a]++; num[b]++; num[c]++; num[d]++; } } for (int i = 0; i < 10; i++) { if (max < num[i]) { max = num[i]; index = i; } } System.out.println(index); } }