def add(S,N,k,i=0): if i == k: return S return add(S.union(N[i]),N,k,i+1) def pull(S,N,k,i=1): if i == k: return S return pull(S.intersection(N[i]),N,k,i+1) N = int(input()) A = [set(input().split(' ')) for i in range(N)] NO = [i for i in A if "NO" in i] YES = [i for i in A if "YES" in i] if YES: n = add(set(),NO,len(NO)) r = pull(YES[0],YES,len(YES)) r2 = r.difference(n.union({"YES",})) print(list(r2)[0]) else: n = add(set(),NO,len(NO)) s = {'1','2','3','4','5','6','7','8','9'} print(n) print(list(s.difference(n))[0])