#include <iostream>

using namespace std;

int p[20];
int fish[20];

void buble_sort(int n){

  for( int i = 0 ; i < n - 1 ; i++ ){
    for( int j = n - 1 ; j > i ; j-- ){
      if( fish[j-1] > fish[j] ){

	int temp1 = fish[j];
	fish[j] = fish[j-1];
	fish[j-1] = temp1;

	int temp2 = p[j];
	p[j] = p[j-1];
	p[j-1] = temp2;

      }
    }
  }


}

int main(void){

  int n;

  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    cin >> p[i] >> fish[i];
  }

  buble_sort(n);

  // for( int i = 0 ; i < n; i++ )cout << p[i] << "---" << fish[i] << endl;

  for( int i = n - 1 ; i > 0 ; i-- ){
    if( fish[i] != fish[i-1] ){
      cout << p[i] << " " << fish[i] << endl;
      return 0;
    }
    if( i == 1 ){
      if( fish[1] == fish[0] )cout << p[0] << " " << fish[0] << endl;
      else cout << p[1] << " " << fish[1] << endl;
    }
  }
}