N=int(input()) Z=[input().split() for i in range(N)] ANS=set() ALL=set() for i in range(10): ANS.add(str(i)) ALL.add(str(i)) for i in range(N): if Z[i][-1][0]=="Y": ANS&=set(Z[i][:-1]) else: ANS&=ALL-set(Z[i][:-1]) print(list(ANS)[0])