import collections n=int(input()) l=[i for i in range(10)] nl=[] for i in range(n): s=input().split() if s[4]=="NO": t=list(map(int,s[:4])) for j in t: if j in l: l.remove(j) elif s[4]=="YES": t=list(map(int,s[:4])) for j in t: if j in l: nl.append(j) if len(l)==1: print(l[0]) else: dd = collections.Counter([x for x in nl if x in l]) print(dd.most_common()[0][0])