import java.util.*; public class no24{ public static void main(String... args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int res[] = new int[10]; int a,b,c,d,check=0; String flag; for(int i = 0; i < n; i++){ a = scan.nextInt(); b = scan.nextInt(); c = scan.nextInt(); d = scan.nextInt(); flag = scan.next(); if(flag.equals("YES")){ res[a]++; res[b]++; res[c]++; res[d]++; check++; }else{ res[a]--; res[b]--; res[c]--; res[d]--; } } for(int i = 0; i < 10; i++){ if(res[i] == check){ System.out.println(i); break; } } } }