N = int(input()) ans = [] for i in range(10): ans.append(i) for i in range(N): turn = input().split() if turn[4] == "YES": turn.remove("YES") turn = [int(x) for x in turn] if len(ans) > 4: ans = turn else: ans = set(ans) & set(turn) else: turn.remove("NO") turn = [int(x) for x in turn] ans = set(ans) - set(turn) ans = list(ans) print(ans[0])