A=[1]*10 for _ in '1'*int(input()): t=input().split() r=t[-1]=='NO' for i in range(10):A[i]*=[r,not r][str(i) in t] print(A.index(1))