import java.util.Scanner;

/**
 * No.24 数当てゲーム
 */
public class No024_NumberHitGame {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();	// 入力列数

        int[] judge = new int[10];
        for (int i=0; i<a; i++) {
        	int n1 = sc.nextInt();	// 数1
        	int n2 = sc.nextInt();	// 数2
        	int n3 = sc.nextInt();	// 数3
        	int n4 = sc.nextInt();	// 数4
            String s = sc.next();	// ジャッジ

            judge[n1] += "YES".equals(s) ? 1 : -1; 
            judge[n2] += "YES".equals(s) ? 1 : -1; 
            judge[n3] += "YES".equals(s) ? 1 : -1; 
            judge[n4] += "YES".equals(s) ? 1 : -1; 
        }

        int max = -1;
        int result = 0;
        for (int i=0; i<judge.length; i++) {
        	if (max < judge[i]) {
        		max = judge[i];
        		result = i;
        	}
        }
        System.out.println(result);
	}

}