N = int(input()) log = [list(map(lambda x: int(x) if x.isdigit() else x,input().split())) for i in range(N)] res = [1] * 10 for l in log: n_set = set(l[:4]) for i in range(10): if l[4] == "YES": if not i in n_set: res[i] &= 0 else: if i in n_set: res[i] &= 0 print(res.index(1))