N=int(input()) cand_y=[0 for _ in range(10)] cand_n=[1 for _ in range(10)] for _ in range(N): A,B,C,D,R=input().split() if R=="YES": cand_y[int(A)]+=1 cand_y[int(B)]+=1 cand_y[int(C)]+=1 cand_y[int(D)]+=1 if R=="NO": cand_n[int(A)]=0 cand_n[int(B)]=0 cand_n[int(C)]=0 cand_n[int(D)]=0 if sum(cand_n)==1: for i in range(10): if cand_n[i]==1: print(i);exit() mx=-1 ans=-1 for i in range(10): if cand_n[i]==0:cand_y[i]=0 if cand_y[i]>mx: mx=cand_y[i] ans=i print(ans)