N = int(input()) ns = [list(input().split()) for _ in range(N)] states = set(range(10)) yesset, noset = set(), set() for nl in ns: r, indexes = nl[-1], set(map(int, nl[:-1])) if r == 'YES': if yesset: yesset &= indexes else: yesset = indexes else: noset |= indexes if answer_set := (yesset - noset): answer = answer_set.pop() else: answer = (states - noset).pop() print(answer)