using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace yukicore { //this algorithm think by claclator class Element where T : IEquatable { public IEnumerable nums; public Element(IEnumerable nums) => this.nums = nums; public Element(Element e) => this.nums = e.nums; public static Element operator -(Element a, Element b) { List rtn = new List(); foreach (var num in a.nums) { if (b.nums.All(x => !x.Equals(num))) rtn.Add(num); } return new Element(rtn); } public static Element operator +(Element a, Element b) { var rtn = new List(); rtn.AddRange(a.nums); rtn.AddRange(b.nums); return new Element(rtn.Distinct().ToArray()); } public static Element operator *(Element a, Element b) { var rtn = new List(); foreach (var num in a.nums) { if (b.nums.Contains(num)) rtn.Add(num); } return new Element(rtn.ToArray()); } } internal class Program { private static void Main(string[] args) { Element mother = new Element(Enumerable.Range(0, 10)); Element rtn = new Element(Enumerable.Range(0, 10)); Console.ReadLine(); while (true) { var tmp = Console.ReadLine(); if (tmp == null || tmp == "") break; var spl = tmp.Split(' '); var inputs = spl.Take(4).Select(x => int.Parse(x)).ToArray(); var flag = spl.Last() == "YES" ? true : false; Element input; if (flag) input = new Element(inputs); else input = new Element(mother - new Element(inputs)); rtn *= input; } Console.WriteLine( rtn.nums.ToArray()[0]); } } }