using System; using System.IO; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Numerics; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using static System.Console; namespace yukicoder { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var ans = Enumerable.Range(0, 10); for (int i = 0; i < n; i++) { var s = Console.ReadLine().Split().ToArray(); var flg = s[4]; var chk = s.Take(4).Select(x => int.Parse(x)); if ("YES".Equals(flg)) { ans = ans.Intersect(chk); } if ("NO".Equals(flg)) { ans = ans.Except(chk); } } Console.WriteLine(ans.First()); } } }