n = int(input()) turn_list = [] nums_dict = {} meta_turn_list = [] for i in range(1, n + 1): turn_list = input().split(" ") if turn_list[4] == "NO": meta_turn_list.append(turn_list) elif turn_list[4] == "YES": meta_turn_list.insert(0, turn_list) for turn_list in meta_turn_list: *nums, ans = turn_list nums = [int(x) for x in nums] if ans == "YES": for j in nums: if j in nums_dict: if nums_dict[j] == "potential": nums_dict[j] = "high-potential" else: nums_dict[j] = "potential" elif ans == "NO": for j in nums: nums_dict[j] = "non-potential" for k in nums_dict: if nums_dict[k] == "high-potential": output = k break missing_numbers = [x for x in range(1, 10) if x not in nums_dict] if len(missing_numbers) == 1: output = missing_numbers[0] # print(meta_turn_list) # print(nums_dict) print(output)