A = ["0","1","2","3","4","5","6","7","8","9"] B = [] N = int(input()) ans = 0 for i in range(N): X = input().split() for c in range(4): if X[-1] == "NO": if X[c] in A: A.remove(X[c]) elif X[c] in B: B.remove(X[c]) else: if X[c] in A: B.append(X[c]) if len(A) == 1: print(A[0]) elif len(B) == 1: print(B[0]) else: for i in range(len(B)): if B.count(B[i]) != 1: ans = B[i] print(ans)