using System; using System.Collections.Generic; using System.Linq; namespace yukicode { public class Program { public static void GetFirstPrediction(ref List nums, ref string answer, ref List prediction) { if (answer == "YES") prediction = nums; else { for (uint i = 1; i <= 9; ++i) { if (nums.IndexOf( i ) == -1) prediction.Add( i ); } } } public static void Predict(ref List nums, ref string answer, ref List prediction) { if (answer == "YES") { prediction = prediction.Intersect( nums ).ToList(); } else { prediction = prediction.Except( nums ).ToList(); } } public static uint Solver(System.IO.TextReader reader) { uint n = uint.Parse( reader.ReadLine() ); var possibleNumbers = new List(); for (var i = 0; i != n; ++i) { var buf = reader.ReadLine().Split(); var nums = buf.Take( 4 ).ToList().ConvertAll( uint.Parse ); if (i == 0) { GetFirstPrediction( ref nums, ref buf[ 4 ], ref possibleNumbers ); } else { Predict( ref nums, ref buf[ 4 ], ref possibleNumbers ); } } return possibleNumbers[0]; } private static void Main() { Console.WriteLine( Solver( Console.In ) ); } } //--- MyLib --- public class MyLib { public static string Ordinalization(int num) { string surfix = "stndrdth"; return string.Format( "{0}{1}", num, ( 0 < num % 10 && num % 10 <= 4 ) && ( ( num % 100 ) / 10 != 1 ) ? surfix.Substring( ( num % 10 - 1 ) * 2, 2 ) : surfix.Substring( 6 ) ); } public static List GetIntList(string input, char delimitor) { return input.Split( delimitor ).ToList().ConvertAll( int.Parse ); } public static List GetIntList(string input, char[] delimitors) { return input.Split( delimitors ).ToList().ConvertAll( int.Parse ); } } }