import java.util.ArrayList; import java.util.Scanner; public class No24 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); ArrayList noList = new ArrayList(); ArrayList yesList = new ArrayList(); for (int i = 0; i < N; i++) { int A = sc.nextInt(); int B = sc.nextInt(); int C = sc.nextInt(); int D = sc.nextInt(); String R = sc.next(); if (R.equals("YES")) { yesList.add(A); yesList.add(B); yesList.add(C); yesList.add(D); } else { noList.add(A); noList.add(B); noList.add(C); noList.add(D); } } if (yesList.size() == 0) { for (int i = 0; i < 10; i++) { if (!noList.contains(i)) { System.out.println(i); } } } else { int mostNo = 0; int mostCount = 0; for (int i : yesList) { if (noList.contains(i)) { continue; } int count = 0; for (int j : yesList) { if (i == j) { count++; } } if (mostCount < count) { mostNo = i; mostCount = count; } } System.out.println(mostNo); } } }