def main(): N = int(input()) yes_list = [] yes_count = 0 no_list = [] no_count = 0 for i in range(N): l = input().split() if l[-1] == "YES": yes_count += 1 for j in range(4): yes_list.append(int(l[j])) else: no_count += 1 for j in range(4): no_list.append(int(l[j])) #print("yes_list", yes_list) #print("no_list", no_list) maybe_yes_from_no_list = [] for i in range(10): if i not in no_list: maybe_yes_from_no_list.append(i) #print("maybe_yes_from_no_list", maybe_yes_from_no_list) maybe_yes_from_yes_list = [] for i in set(yes_list): if yes_list.count(i) == yes_count: maybe_yes_from_yes_list.append(i) #print("maybe_yes_from_yes_list", maybe_yes_from_yes_list) if len(maybe_yes_from_no_list) == 1: print(maybe_yes_from_no_list[0]) elif len(maybe_yes_from_yes_list) == 1: print(maybe_yes_from_yes_list[0]) else: intersection = set(maybe_yes_from_yes_list) & set(maybe_yes_from_no_list) print(list(intersection)[0]) if __name__ == '__main__': main()