using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main(string[] args) { var input = new List(); string line = Console.ReadLine(); while (line != string.Empty) { Console.WriteLine(line); input.Add(line.Split(' ')); line = Console.ReadLine(); } foreach (string[] ar in input) { Console.WriteLine(string.Join(", ", ar)); } var candidates = new List() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; for (int i = 1; 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]); } }