turn = int(input()) canditate = {i for i in range(10)} for i in range(turn): ans = input().split() ans_1 = set(map(int, ans[0:-1])) if ans[-1] == "NO": canditate -= ans_1 else: canditate &= ans_1 if canditate: print(list(canditate)[0])