using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Application { class MainClass { public static void Main (string[] args) { var N = readInt (' '); var ns = new int[10]; for (int i = 0; i < ns.Length; i++) { ns [i] = 1; } for (int i = 0; i < N; i ++) { var L = readItems (' '); var a = int.Parse (L [0]); var b = int.Parse (L [1]); var c = int.Parse (L [2]); var d = int.Parse (L [3]); var ds = new int[]{a,b,c,d}; var r = L [4]; if (r == "NO") { foreach (var idx in ds) { ns [idx] = 0; } } else { foreach (var idx in ds) { { if (ns [idx] == 0) { continue; } ns [idx]++; } } } } int max = int.MinValue; int result = -1; for (int idx = 0; idx < ns.Length ; idx++) { if (ns[idx] > max) { max = ns [idx]; result = idx; } } writeLine (result); } static void writeLine (object o) { System.Console.WriteLine (o.ToString ()); } static String[] readItems (char c) { return System.Console.ReadLine ().Split (c); } static int readInt (char c) { return readInts (c) [0]; } static int[] readInts (char c) { return readItems (c).Select (x => int.Parse (x)).ToArray (); } } }