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 { public int[] nums; public Element(int[] nums) => this.nums = nums; public Element(Element e) => this.nums = e.nums; public static Element operator -(Element a, Element b) { var rtn = new List(); foreach (var num in a.nums) { if (b.nums.All(x => x != num)) rtn.Add(num); } return new Element(rtn.ToArray()); } 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).ToArray()); Element rtn = new Element(Enumerable.Range(0, 10).ToArray()); 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[0]); } } }