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 ("YES".equals((sc.next()))) { flg &= 1 << a; flg &= 1 << b; flg &= 1 << c; flg &= 1 << d; for (int j = 0; j < 11; j++) { if (j == a || j == b || j == c || j == d) flg &= 0 << j; } } else { 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; } } } }