if __name__ == '__main__':
arr = []
for _ in range(int(input())):
name = input()
score = float(input())
arr1 = [name, score]
arr.append(arr1)
arr.sort(key=lambda x: x[1])
# print(arr)
# print(min(arr,key=lambda x:x[1]))
arr.remove(min(arr,key=lambda x:x[1]))
# print(arr)
minimum = min(arr,key=lambda x:x[1])
# print(minimum[1])
a=[]
minimum = minimum[1]
for i in arr:
if(i[1] == minimum):
a.append(i[0])
a.sort()
for i in a:
print(i)