import java.util.Arrays; import java.util.Scanner; public class Sample001 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); boolean num[] = new boolean[10]; Arrays.fill(num, true); for (int i = 0; i < N ; i++ ) { int A = sc.nextInt(); int B = sc.nextInt(); int C = sc.nextInt(); int D = sc.nextInt(); String jiro = sc.next(); if(jiro.equals("YES")) { for(int j = 0; j < 10; j++) { if(j!=A&&j!=B&&j!=C&&j!=D) num[j] = false; } } else if(jiro.equals("NO")) { num[A] = false; num[B] = false; num[C] = false; num[D] = false; } } for(int i = 0; i < 10; i++) { if(num[i]) System.out.println(i); } } }