import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int TMP = 0xffff; for(int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); boolean ok = sc.next().equals("YES")?true:false; if(ok) TMP &= ((1 << a) | (1 << b) | (1 << c) | (1 << d)); else TMP &= ~((1 << a) | (1 << b) | (1 << c) | (1 << d)); } for(int i = 0; i < 10; i++) { if((TMP & (1 << i)) != 0) System.out.println(i); } } }