#include<bits/stdc++.h>
using namespace std;
string name,name_max;
int n;
double score,score_max;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>name>>score;
if(i==1){
score_max=score;
name_max=name;
}else{
if(score>score_max){
score_max=score;
name_max=name;
}
}
}
cout<<name_max;
return 0;
}