def main(): n = int(input()) dic = [1] * 10 for i in range(n): tmp = input().split() for j in range(4): dic[int(tmp[j])] *= [0, 2][tmp[-1] == "YES"] print(dic.index(max(dic))) main()