import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
HashMap<Integer, Integer> map=new HashMap();
int a,b;
for(int i=0;i<n;i++){
a=scanner.nextInt();
b=scanner.nextInt();
if (map.get(a)!=null) {
b+=map.get(a);
map.put(a, b);
}else{
map.put(a, b);
}
}
int max1=0,max2=0;
for (Map.Entry<Integer, Integer> entry:map.entrySet()) {
if (entry.getValue()>max2) {
max2=entry.getValue();
max1=entry.getKey();
}
}
System.out.println(max1+" "+max2);
}
}
class Student1{
Integer num;
Integer grade;
public Student1(Integer num,Integer grade) {
// TODO Auto-generated constructor stub
this.num=num;
this.grade=grade;
}
}