from collections import Counter N=int(input()) string_list=[input() for i in range(N)] B=[] C=[] D=[i for i in range(10)] for i in range(N): A=string_list[i].split() if A[4]=="YES": B.append(A[:-1]) else: C.append(A[:-1]) if len(B)==0: E=[int(fla) for ine in C for fla in ine] E=set(E) F=list(set(D) ^ E) print(F[0]) else: E=[fla for ine in B for fla in ine] counter = Counter(E) print(counter.most_common(1)[0][0])