def main(): N = int(input()) numbers = set(range(10)) for i in range(N): *X, R = input().split() X = set(map(int,X)) if R == 'YES': numbers = numbers & X else: numbers = numbers - X print(*numbers) if __name__ == '__main__': main()