#include
#include
#define MANX 100
int main()
{
int school[MANX],N,i,s,MAX,k,score;
memset(school,0,sizeof school);
scanf("%d",&N);
for(i=1;i<=N;i++){
scanf("%d %d",&s,&score);
school[s]=school[s]+score;
};
for(i=1;ischool[i-1])
{ MAX=school[i];k=i;
}
}
printf("%d %d",k,MAX);
return 0;
}