N = int(input()) YES = [0]*10 NO = [0]*10 for _ in range(N): q = input().split() num = list(map(int, q[:4])) R = q[4] if R == 'YES': for i in num: YES[i] += 1 if R == 'NO': for i in num: NO[i] += 1 if sum(NO) == N*4: print(NO.index(0)) else: for i in range(10): if NO[i]: YES[i] = 0 print(YES.index(max(YES)))