import java.util.Scanner; public class Main { public static void main(String[] p) { Scanner q = new Scanner(System.in); int n = q.nextInt(); char f = 0x3FF; char z = 0x0; for (int i = 0; i < n; i++) { int a = q.nextInt(); int b = q.nextInt(); int c = q.nextInt(); int d = q.nextInt(); f &= ("YES".equals((q.next()))) ? (z | 1 << a | 1 << b | 1 << c | 1 << d) : ~(z | 1 << a | 1 << b | 1 << c | 1 << d); } for (int i = 0; i < 11; i++) { if ((f & 1 << i) != 0) { System.out.println(i); break; } } } }