using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Magatro { static void Main() { int N = int.Parse(Console.ReadLine()); bool[] A = new bool[10]; for(int i = 0; i < N; i++) { string[] s = Console.ReadLine().Split(' '); if (s[4] == "NO") { for(int j = 0; j < 4; j++) { A[int.Parse(s[j])] = true; } } else { bool[] q = (new bool[10]).Select(ss => true).ToArray(); for(int j = 0; j < 4; j++) { q[int.Parse(s[j])] = false; } for(int j = 0; j < 10; j++) { A[j] |= q[j]; } } } int e = 0; for(int i = 0; i < 10; i++) { if (!A[i]) { e = i; } } Console.WriteLine(e); } }