n = int(input()) org_list = list('0123456789') for i in range(n): inputed_list = list(input().split()) if inputed_list[-1] == 'NO': for i in range(len(inputed_list) - 1): if inputed_list[i] in org_list: org_list.remove(inputed_list[i]) else: tmp_list = list('0123456789') for i in range(len(inputed_list) - 1): if inputed_list[i] in tmp_list: tmp_list.remove(inputed_list[i]) for e in tmp_list: if e in org_list: org_list.remove(e) print(org_list[0])