#include<bits/stdc++.h>
using namespace std;
struct M {
int num;
int score;
bool operator <(const M & a) {
if(num==a.num) {
score+=a.score;
} else return score>a.score;
};
};
int main() {
int n;
while(cin>>n) {
M m[n];
for(int i=0; i<n; i++) {
cin>>m[i].num>>m[i].score;
}
sort(m,m+n);
cout<<m[0].num<<" "<<m[0].score<<endl;
}
return 0;
}