using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace template { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); bool[] ret = new bool[10]; for (int i = 0; i < n; i++) { string[] s = Console.ReadLine().Split(); if (s[4] == "YES") { for (int j = 0; j < 10; j++) { if (Array.IndexOf(s, j.ToString()) < 0) ret[j] = false; } } else { for (int j = 0; j < 4; j++) { ret[int.Parse(s[j])] = false; } } } for (int i = 0; i < 10; i++) { if (ret[i]) Console.WriteLine(i); } } } }