uni = {'1', '2', '3', '4', '5', '6', '7', '8', '9'} for _ in range(int(input())): line = input().split() if line[-1] == 'YES': uni = uni & set(line[:-1]) elif line[-1] == 'NO': uni = uni - set(line[:-1]) print(list(uni)[0])