N = int(input()) a= [input().split() for _ in range(N)] s = set() k = set([i for i in range(10)]) for i in range(N): if a[i][4] == "NO": s.add(int(a[i][0])) s.add(int(a[i][1])) s.add(int(a[i][2])) s.add(int(a[i][3])) else: b = set() b.add(int(a[i][0])) b.add(int(a[i][1])) b.add(int(a[i][2])) b.add(int(a[i][3])) k = k.intersection(b) if len(k) == 1: for i in k: print(i) exit() for i in range(10): if not i in s and i in k: print(i) exit()