n = int(input()) ng, ok = [], [] for _ in range(n): l = list(input().split()) for i in range(4): if l[-1]=='YES': ok.append(int(l[i])) else: ng.append(int(l[i])) ret = None for i in range(10): if i not in ng: if ok.count(i)==n: ret = i break if ret: print(ret) else: for i in range(10): if i not in ng: print(i)