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 not in nums_dict: nums_dict[j] = "potential" elif nums_dict[j] == "non-potential": nums_dict[j] = "conflict" elif ans == "NO": for j in nums: if j not in nums_dict: nums_dict[j] = "non-potential" elif nums_dict[j] == "potential": nums_dict[j] = "non-potential" output = None for k in nums_dict: if nums_dict[k] == "potential" or nums_dict[k] == "conflict": output = k break if output is None: 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)