#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,first = 0,second = 0,findex = 0,sindex;
  
  cin >> n;
  
  vector<string>s(n);
  vector<int>t(n);
  for(int i = 0;i < n;i++){
    cin >> s.at(i) >> t.at(i);
    
    if(first < t.at(i)){
      second = first;
      first = t.at(i);
      sindex = findex;
      findex = i;    
    }else if(second < t.at(i)){
      second = t.at(i);
      sindex = i;
    }
  }

  cout << s.at(sindex) << endl;
}

/*                          AUTHOR
                            (_|_)
                             \_/
_______________________ÃMIT SÃRKER KISHÕR_______________________
----------------------------------------------------------------
_____DEPARTMENT OF CSE, CITY UNIVERSITY, DHAKA, BANGLADESH______
----------------------------------------------------------------
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ci std ::cin
#define co std ::cout
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld%lld",&n,&m)
#define pd(n) printf("%d",n)
#define pdd(n,m) printf("%d%d",n,m)
#define pl(n) printf("%lld",n)
#define pll(n,m) printf("%lld%lld",n,m)
#define p_line printf("\n")
#define line cout<<"\n"
#define cas(n) printf("Case %d: ",n++)
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define pb push_back
#define mkp make_pair
#define pi acos(-1)
const ll mx=100000;
const ll mod=1e9+7;
/*
ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}
*/
/*
ll bigMod(ll a, ll b)
{
    if(b<=0)
    {
        return 1;
    }
    ll value=bigMod(a,b/2);
    value=(value*value)%mod;
    if(b%2==1)
        value=(value*a)%mod;
    return value;
}
*/
/*
struct st
{
    int value;
    int pos; 
};
*/
/*
bool cmp(st n,st m)
{
    return n.a>m.a;
}
*/
/*
bool cmp(int n,int m)
{
    return m>n;
}
*/
void solve()
{
    //Code here
    int t=1;
    // ci>>t;
    while(t--)
    {
        int n;
        cin>>n;
        priority_queue<pair<int,string>>pq;
        for(int i=0 ; i<n ; i++)
        {
        	string name;
        	int high;
        	cin>>name>>high;
        	pq.push({high,name});
        }
        pq.pop();
        auto it=pq.top();
        cout<<it.second;
        line;
    }
}
void I_O()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    I_O();
    solve();
    //line;
    return 0;
}