#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long n, q; cin >> n >> q;
	long long l[100010] = { 0 };
	for (int i = 0; i < n; i++){
		long long a, b; cin >> a >> b;
		l[a] += b;
	}
	int num = 0;
	int maxs = 0;
	for (int i = 1; i < n + 1; i++){
		if (maxs < l[i]){
			num = i;
		}
		else if (maxs == l[i]) {
			num = min(num, i);
		}
	}
	cout << num << endl;
}