#include <iostream>
#include <algorithm>
 
using namespace std;
 
 
int main(void) {
  int score[21], cscore[21], n, a, b;
 
  cin >> n;
 
  for(int i = 1; i < 21; i++) {
    score[i] = 0; cscore[i] = 0;
  }
 
  for(int i = 1; i < n+1; i++) {
    cin >> a >> b;
    score[a] = b;
  }
 
  for(int i = 1; i < n+1; i++) {
    cscore[i] = score[i];
    score[i] *= 1000;
    score[i] += i*10;
  }
   
  sort(score+1, score + n + 1);
 
  for (int i = 1; i < n+1; i++) {
    if(cscore[i] == score[n]/1000) {
      cout << i << " " << cscore[i] << endl;
      break;
    }
  }
  return 0;
}