#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  vector<pair<int,int>> p;
  REP(i,n){
    int a,v;
    cin>>a>>v;
    p.PB(MP(v,a));
  }
  sort(ALL(p));
  int maxi=p.back().FR;
  int par=p.back().SC;
  for(int i=p.size()-1;i>=0;i--){
    if(p[i].FR==maxi){
      par=min(par,p[i].SC);
    }
  }
  cout<<par<<' '<<maxi<<endl;
  return 0;
}

