import java.util.Arrays; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), a,b,c,d, s; boolean[] bo = new boolean[10]; Arrays.fill(bo, true); for(int i = 0; i < n; i++){ a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt(); s = sc.next().length(); if(s == 2){ bo[a] = false; bo[b] = false; bo[c] = false; bo[d] = false; } else { for(int j = 0; j < 10; j++){ if(a != j && b != j && c != j && d != j){ bo[j] = false; } } } } for(int j = 0; j < 10; j++){ if(bo[j]){ System.out.println(j); return; } } } }