using System; using System.Linq; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] b = new int[10]; for (int i = 0; i < 10; i++) { b[i] = 0; } string ans = ""; for (int i = 0; i < n; i++) { string[] s = Console.ReadLine().Split(' '); if (s[4] == "YES") { for (int j = 0; j < 4; j++) { if (b[int.Parse(s[j])] == 1) { ans = s[j]; } else { b[int.Parse(s[j])] = 1; } } } else { for (int j = 0; j < 4; j++) { b[int.Parse(s[j])] = -1; } } } if (ans == "") { ans = Array.IndexOf(b, 0).ToString(); } Console.WriteLine(ans); } }