if __name__ == '__main__':
single_list=[]
nested_list=[]
score_list=[]
for _ in range(int(input())):
name = input()
score = float(input())
score_list.append(score)
nested_list.append([name,score])
nested_list=sorted(nested_list)
sorted_score=sorted(score_list)
minNumber=sorted_score[0]
for score in sorted_score:
if score>minNumber:
second_less=score
break
for single in nested_list:
if single[1]==second_less:
print(single[0])