#include<cstdio>
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define LL long long
using namespace std;

template <class I>
inline void read(I &z)
{
    z=0;
    char c=getchar();int base=1;
    while (!isdigit(c) && c!='-') c=getchar();
    if (c=='-') c=getchar(),base=-1;
    while (isdigit(c)) z=z*10+c-'0',c=getchar();
    z*=base;
}

struct node
{
    int h,x;
};

node a[1010];
int n,h;

char s[1010][20];

bool comp(node x,node y)
{
    return x.h>y.h;
}

int main(int argc, char const *argv[])
{
    read(n);
    for (int i=1;i<=n;++i)
    {
        scanf("%s",s[i]+1);
        read(h);
        a[i]=(node){h,i};

    }
    sort(a+1,a+n+1,comp);
    printf("%s",s[a[2].x]+1);
    return 0;
}

#include<bits/stdc++.h>
#define int         int64_t
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mi        map<int,int>
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
void solve(){
    int n; cin>>n;
    pair<int,string> arr[n];
    rep(i,0,n){
        string s; int p;
        cin>>s>>p;
        arr[i].first=p;
        arr[i].second=s;
    }
    sort(arr,arr+n);
    cout<<arr[n-2].second;
}
signed main(){
    ios
    
        
    int test=1;
    //cin>>test;
    while(test--){
        solve();
    }    
    return 0;
}