/* stuff you should look for
	* int overflow, array bounds, uppercase/lowercase
	* special cases (n=1?)
	* do sth. instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/
#include<cstdio>
#include<string>
#include<iostream>
#include<map>
char s[15];
std::map<int,std::string> mp;
int main() {
	int n; scanf("%d",&n);
	for(register int i=1;i<=n;++i) {
		int v;
		scanf("%s%d",s,&v);
		std::string str=s;
		mp[v]=str;
	}
	std::map<int,std::string>::iterator it=mp.end(); --it; --it;
	printf("%s\n",it->second.c_str());
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
struct sa{
    string nam;
    int gd;
}a[1005];
int n;
bool cmp(sa x,sa y){
    return x.gd<y.gd;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i].nam>>a[i].gd;
    }
    sort(a+1,a+n+1,cmp);
    cout<<a[n-1].nam;
    return 0;
}