import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) A=[[str(i) for i in input().split()] for _ in range(n)] Ans=[True]*10 for i in range(n): if A[i][4]=="NO": for j in range(4): Ans[int(A[i][j])-1]=False else: S=set() for j in range(4): S.add(int(A[i][j])-1) for j in range(10): if j not in S: Ans[j]=False for i in range(10): if Ans[i]: print(i+1) break