using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class yc2
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] nums = new int[10];
        int answer = 0;
        string[] str;

        for (int i = 0; i < N; i++)
        {
            str = Console.ReadLine().Split();

            if (str[4] == "YES")
            {
                for (int j = 0; j < 4; j++)
                {
                    nums[int.Parse(str[j])]--;
                }
                answer--;
            }
            else
            { //(str[4] == "NO")
                for (int j = 0; j < 4; j++)
                {
                    nums[int.Parse(str[j])]++;
                }
            }
        }
        for (int i = 0; i < 10; i++)
        {
            if (nums[i] == answer)
            {
                Console.WriteLine(i);
                return;
            }
        }

    }
}