N = int(input()) List = [] Numset = [0,1,2,3,4,5,6,7,8,9] for i in range(N): List.append(input().split()) for i in range(N): if List[i][4] == "NO": a = int(List[i][0]) b = int(List[i][1]) c = int(List[i][2]) d = int(List[i][3]) if a in Numset: Numset.remove(a) if b in Numset: Numset.remove(b) if c in Numset: Numset.remove(c) if d in Numset: Numset.remove(d) if List[i][4] == "YES": for j in range(len(Numset)): if j != int(List[i][0]) and j != int(List[i][1]) and j != int(List[i][2]) and j != int(List[i][3]): if j in Numset: Numset.remove(j) print(int(Numset[0]))