#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct cpy
{
int id;
string name;
int money;
}a[100];
int cmp(cpy x, cpy y)
{
if(x.money == y.money)
{
return x.id < y.id;
}else
{
return x.money > y.money;
}
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i ++ )
{
a[i].id = i;
cin >> a[i].name >> a[i].money;
}
sort(a, a + n , cmp);
cout << a[0].name;
return 0;
}