# coding:utf-8 n = int(input()) ans_list = [str(i) for i in range(10)] taro_list = [] yes_list = [] for i in range(n): taro_list.append(input().split()) for j in range(n): if taro_list[j][4] == 'NO': for k in range(4): try: ans_list[ans_list.index(taro_list[j][k])] = '-' except ValueError: continue elif taro_list[j][4] == 'YES': for k in range(4): yes_list.append(taro_list[j][k]) print(ans_list) print(yes_list) if ans_list.count('-') == 9: ans = [i for i in ans_list if i != '-'] print(ans[0]) elif ans_list.count('-') == 0: ans = [i for i in yes_list if yes_list.count(i) == 2] print(ans[0]) else: ans_choice = [i for i in ans_list if i != '-'] ans = [i for i in ans_choice if yes_list.count(i) != 2] print(ans[0])