N = int(input()) A = []#数値 B = [] C = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] C = set(C) for i in range(N): turn = input().split() if turn[-1] == "Yes": A.append(turn[:-1]) else: B.append(turn[:-1]) A_s = set(sum(A, [])) B_s = set(sum(B, [])) candidate = A_s - B_s A_2 = list(map(set,A)) if len(A) >= 2: D = A_2[0] & A_2[1] for i in range(len(A) - 2): D = D & A_2[i+2] print(D & candidate) elif len(A) == 1: print (candidate) else : print (C - B_s)