N = int(input()) res = [1 for _ in range(10)] for _ in range(N): *a, r = input().split() a = list(map(int, a)) d = [0 for _ in range(10)] for i in range(4): d[a[i]] = 1 if r == 'YES': for i in range(10): if not d[i]: res[i] = 0 else: for i in range(10): if d[i]: res[i] = 0 for i in range(10): if res[i]: print(i)