#include <iostream>
using namespace std;

int main()
{
  int a[21], b[21];
  int n;
  int max = 0;
  int min = 1000;
  cin >> n;
  for (int i = 1; i <= n; i++){
    cin >> a[i] >> b[i];
    if (b[i] >= max){
      max = b[i];
    }
  }
  
  for (int i = 1; i <= 6; i++){
    if (b[i] == max){
      if (min > i){
        min = i;
      }
    }
  }

  cout << min << " " << max << endl;

  return 0;

}