from collections import * from itertools import * from functools import * from heapq import * import sys,math # input = sys.stdin.readline N = int(input()) ans = set([str(i) for i in range(10)]) for _ in range(N): X = list(input().split()) s = set(X[:-1]) if X[-1]=='YES': ans &= s else: ans -= s print(*ans)