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(x) for y in C for x in y] E=set(E) F=list(set(D) ^ E) print(F[0]) else: E=[int(x) for y in C for x in y] E=set(E) F=[int(x) for y in B for x in y] F=set(F) G=list((F & E)^ F) print(G[0])