import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char flg = 0x03FF; for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); char z = 0x0000; if ("YES".equals((sc.next()))) { flg &= (z | 1 << a | 1 << b | 1 << c | 1 << d); } else { flg &= ~(z | 1 << a | 1 << b | 1 << c | 1 << d); } } for (int i = 0; i < 11; i++) { if ((flg & 1 << i) != 0) { System.out.println(i); break; } } } }