import java.util.Arrays; import java.util.List; import java.util.Scanner; public class NumberGuessing { public static void main(String[] args) { int[] numList = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 0; i < n; i++) { Integer guessNum1 = scanner.nextInt(); Integer guessNum2 = scanner.nextInt(); Integer guessNum3 = scanner.nextInt(); Integer guessNum4 = scanner.nextInt(); List guessNumList = Arrays.asList(guessNum1, guessNum2, guessNum3, guessNum4); String answer = scanner.next(); if (answer.equals("NO")){ for (int guessNum : guessNumList) { numList[guessNum] = 0; } } if (answer.equals("YES")) { for (int k = 0; k < 10; k++) { if (guessNumList.contains(k)) { if (numList[k] != 0) { numList[k] = 1; } } else { numList[k] = 0; } } } } for (int i = 0; i < 10; i++) { if (numList[i] == 1 || numList[i] == -1) { System.out.println(i); } } } }