#include<bits/stdc++.h>
using namespace std;
string b[100000];
int n,a[100000],c[10000],m;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>b[i];
	    cin>>a[i];
		c[i]=a[i];
	}
	sort(c,c+n);
		for(int j=1;j<=n;j++){
			if(c[n-2]==a[j]){
				m=j;
			}
		}
		cout<<b[m]<<endl;;
	return 0;
}
 

#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)

signed main(void)
{
	int n; cin >> n;
	int ans[3000] = {6, 10, 15};
	int i = 3;
	reps (j, 16, 1000000)
	{
		if (j%6&&j%10&&j%15) continue;
		ans[i] = j;
		i++;
		if (i > 2505) break;
	}

	rep (j, n) cout << ans[j] << ' ';
	cout << endl;
}
