using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main(string[] args) { var input = new List(); int count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { input.Add(Console.ReadLine().Split(' ')); } var candidates = new List() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; for (int i = 0; i < input.Count; i++) { if (input[i][4] == "YES") { var targets = new List(); foreach (string candidate in candidates) { if (!input[i].Contains(candidate)) { targets.Add(candidate); } } foreach (string target in targets) { candidates.Remove(target); } } else { for (int j = 0; j < 4; j++) { candidates.Remove(input[i][j]); } } } Console.WriteLine(candidates[0]); } }