import java.util.Arrays; import java.util.Scanner; public class No24 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); int a, b, c, d; boolean r[] = new boolean[10]; Arrays.fill(r, true); for (int i = 0; i < n; i++) { a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt(); if (args[(i + 1) * 5].length() == 3) { for (int j = 0; j < 10; j++) if (j != a && j != b && j != c && j != d) r[j] = false; } else { r[a] = r[b] = r[c] = r[d] = false; } } for(int i=0;i<10;i++)if(r[i])System.out.println(i); } }