import statistics a=int(input()) c=[0,1,2,3,4,5,6,7,8,9] d=[] e=[] for i in range(a): b=input().split() if b[4]=="NO": d.append(int(b[0])) d.append(int(b[1])) d.append(int(b[2])) d.append(int(b[3])) else: e.append(int(b[0])) e.append(int(b[1])) e.append(int(b[2])) e.append(int(b[3])) if len(d)==12: for i in c: if i not in d: print(i) else: for i in e: if (e.count(i)>=len(e)//4) and (i not in d): print(i) break