N = int(input()) anslist = [] for i in range(N): anslist.append(input().split()) ans_yes = [] ans_no = [] for _ in anslist: if _[4] == "YES": for k in range(4): ans_yes.append(_[k]) else: for k in range(4): ans_no.append(_[k]) # s = set() # ans_yes = [x for x in ans_yes if x in s or s.add(x)] uq_ans_yes = [] for _ in ans_yes: if _ not in uq_ans_yes: uq_ans_yes.append(_) ans_yes = uq_ans_yes uq_ans_no = [] for _ in ans_no: if _ not in uq_ans_no: uq_ans_no.append(_) ans_no = uq_ans_no # print(ans_yes) # print(ans_no) if len(ans_no) == 9: for i in range(10): if str(i) not in ans_no: print(i) elif len(ans_no) == 0: s = set() ans_yes = [x for x in ans_yes if x in s or s.add(x)] print(ans_yes[0]) else: # s = set() # ans_yes = [x for x in ans_yes if x in s or s.add(x)] for _ in ans_no: if _ in ans_yes: ans_yes.remove(_) # print(ans_yes) print(ans_yes[0])