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(); if ("NO".equals((sc.next()))) { flg &= 0 << a; flg &= 0 << b; flg &= 0 << c; flg &= 0 << d; } } for (int i = 0; i < 11; i++) { if ((flg & 1 << i) != 0) { System.out.println(i); break; } } } }