#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
cin>>n;
vector<int>in;
vector<int>no;
rep(i,n){
int a,b;
cin>>a>>b;
pb(in,b);
pb(no,a);
}
rep(i,2*n){
rep(j,n-1){
if(in[j]<in[j+1]){swap(in[j],in[j+1]);swap(no[j],no[j+1]);}
if(in[j]==in[j+1]&&no[j]<no[j+1])swap(no[j],no[j+1]);
}
}
cout<<no[0]<<" "<<in[0]<<endl;
}