#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int n;
	int s[105] = {};
	int sa[105] = {};
	cin >> n;
	for (int i = 0;i < n;i++) {
		int a, v;
		cin >> a >> v;
		s[a - 1] += v;
		sa[a - 1] = s[a - 1];
	}
	sort(sa, sa + 105);

	for (int i = 0;i < 25;i++) {
		if (sa[104] == s[i]) {
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;

}