marksheet = []
for _ in range(0,int(input())):
marksheet.append([input(),float(input())])
second_highest=sorted(list(set(marks for name,marks in marksheet)))[1]
print('
'.join([a for a,b in sorted(marksheet) if b == second_highest]))
https://www.hackerrank.com/challenges/nested-list/problem