#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int n;
	long a, b;
	long v[110] = {0}, v2[110] = {0};
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++){
		scanf("%ld %ld", &a, &b);
		v[a] += b;
		v2[a] += b;
	}
	
	sort(v, v + n + 1);
	reverse(v, v + n + 1);
	
	for (int i = 0; i <= n; i++){
		if (v2[i] == v[0]){
			printf("%ld %ld\n", i, v2[i]);
			break;
		}
	}
}