#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

map<int, int>mp;
int main() {
	int n; cin >> n;
	rep(i, n) {
		int a, v; cin >> a >> v;
		mp[a] += v;
	}
	vector<P>V;
	for (P i : mp)V.push_back(i);
	stable_sort(V.begin(), V.end(), [](P a, P b) {return a.second > b.second; });
	cout << V[0].first << ' ' << V[0].second << endl;
}