# codeup 1369
# n, k = map(int, input().split())
# for i in range(n):
# for j in range(n):
# if i == 0 or j == 0 or i == n-1 or j == n-1:
# print('*', end='')
# elif (i+j+1) % k == 0:
# print('*', end='')
# else:
# print(' ', end='')
# print()
# codeup 1677
# n, m = map(int, input().split())
# for i in range(m):
# for j in range(n):
# if (i == 0 and j == 0) or (i == 0 and j == n - 1) or (i == m - 1 and j == 0) or (i == m - 1 and j == n - 1):
# print('+', end='')
# elif j == 0 or j == n-1:
# print('|', end='')
# elif i == 0 or i == m-1:
# print('-', end='')
# else:
# print(' ', end='')
# print()
# List
# data = []
#
# data.append(10)
# data.append(20)
# data.pop()
# # data.append([10, 20, 30])
# data.extend([10, 20, 30])
# print(data)
#
# x = data.count(10)
# data = []
# for i in range(10):
# data.append(i)
#
# print(data[:])
# print(min(data))
# print(max(data))
# print(sum(data))
# codeup 1411
# N = int(input())
# a = 0
# data = []
# for i in range(N-1):
# a = int(input())
# data.append(a)
# total = []
# for i in range(1, N+1):
# total.append(i)
# a = sum(total) - sum(data)
# print(a)
# N = int(input())
# data = [0] * (N+1)
# for i in range(N-1):
# v = int(input())
# data[v] = 1
#
# data.pop(0)
# print(data)
#
# data.index(0)
#
# for i in range(N):
# if data[i] == 0:
# print(i+1)
# break
# codeup 1410
# n = input()
# n = list(n)
# a = n.count('(')
# b = n.count(')')
# print(a, b)
# codeup 1420
# data = []
# first = -90
# second = 0
# third = 0
# n = int(input())
# for i in range(n):
# name, score = input().split()
# data.append([name, int(score)])
#
# for i in range(n):
# third = second
# second = first
# first = data[i][1]
# print(first, second, third)
#
#
# print(third)
# import deepcopy
name = []
score = []
dummy = []
n = int(input())
for i in range(n):
v, x = input().split()
name.append(v)
score.append(int(x))
dummy.append(int(x))
findItem = dummy.sort()[n - 2]