num = [1] * 10 n = int(input()) for _ in range(n): temp = input().split() a = list(map(int, temp[:4])) for i in a: if temp[4] == "YES" and num[i] >= 1: num[i] += 1 else: num[i] = 0 print(num.index(max(num)))