N = int(input()) S = set(str(i) for i in range(10)) for _ in range(N): *X, R = input().split() X = set(X) if R == 'NO': S -= X else: S &= X print(*S)