N = int(input()) inp = [] for i in range(N): inp.append(input().split()) cards = list('0123456789') pos = [] for t in inp: isIn = t.pop(-1) if isIn == "NO": for n in t: if n in cards: cards.remove(n) else: break else: common = list(set(t) & set(pos)) if common: pos = common else: pos.extend(t) pos = list(set(pos)) if len(set(cards) & set(pos)) == 1: ans = list(set(cards) & set(pos))[0] else: ans = cards[0] print(ans)