public static void main(String[] args){
Scanner input = new Scanner(System.in);
int guest = Integer.parseInt(input.nextLine());
String bestGuest = "";
int highestFun = 0;
for(int x = 0; x < guest; x++){
String line = input.nextLine();
String[] parts = line.split(" ");
String guestName = parts[0];
int fun = Integer.parseInt(parts[1]);
if(fun > highestFun) {
highestFun = fun;
bestGuest = guestName;
}
}
System.out.println(bestGuest);
}