#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int ta[10000]={0},n;
	cin>>n;
	for(int i=0;i<n;i++){
	int a,b;
	cin>>a>>b;
	ta[a]+=b;
	}
	int ans=0,ansi=0;
	for(int i=0;i<10000;i++)if(ans<ta[i])ans=ta[i],ansi=i;
	cout<<ansi<<" "<<ans<<endl;
	return 0;
}