def main(): N = int(input()) yes = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) no = set() for i in range(N): s = input() if s[8] == 'N': no = no | set(list(map(int, s[0:7].split(' ')))) else: yes = yes & set(list(map(int, s[0:7].split(' ')))) print(list(set(yes) - set(no))[0]) if __name__ == '__main__': main()