N = int(input()) yes = [] no = [] for n in range(N): L = input().split() if L[-1] == 'YES': yes.extend(L[0:4]) else: no.extend(L[0:4]) if len(yes) == 0: for i in range(10): if not str(i) in no: print(i) elif len(no) != 0: for n in no: if n in yes: yes.remove(n) count = 0 ans = '' for i in range(10): if yes.count(str(i)) > count: count = yes.count(str(i)) ans = i print(ans) else: count = 1 ans = '' for i in range(10): if yes.count(str(i)) > count: count = yes.count(str(i)) ans = i print(ans)