#include<stdio.h>
const int maxn = 100000;
int school[maxn] = {0};
int main() {
int N;
scanf("%d",&N);
int x,score;
for(int i=0; i<N; i++) {
scanf("%d %d",&x,&score);
school[x]+=score;
}
int max = 1,k = 1;
for(int i=1; i<=N; i++) {
if(school[i]>=max) {
max = school[i];
k = i;
}
}
printf("%d %d",k,max);
return 0;
}