import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[] isNotTrue = new boolean[10]; for (int i = 0; i < n; i++) { HashSet used = new HashSet<>(); for (int j = 0; j < 4; j++) { used.add(sc.nextInt()); } if ("YES".equals(sc.next())) { for (int j = 0; j < 10; j++) { if (!used.contains(j)) { isNotTrue[j] = true; } } } else { for (int j = 0; j < 10; j++) { if (used.contains(j)) { isNotTrue[j] = true; } } } } for (int i = 0; i < 10; i++) { if (!isNotTrue[i]) { System.out.println(i); return; } } } }