#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;
#define pb push_back
#define ms(a, b); memset(a, b, sizeof(a));
#define all(x) x.begin(), x.end()
#define endl "\n"
#define ins insert
#define bck back
#define lb lower_bound
#define ub upper_bound
#define popcount(x)  __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define clz(x) __builtin_clz(x)
const int inf = 0x3f3f3f3f, mod = 1e9+7, mx = 2e5+10, LOGN = 21;
const ll infll = 0x3f3f3f3f3f3f3f3f;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vector<pair<int, string>> a(n);
	for(int i=0; i < n; i++)cin >> a[i].second >> a[i].first;
	sort(all(a));
	cout << a[n-2].second << "\n";
	return 0;
}

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n;
  cin>>n;
  map<int,string> mount{};
  vector<int> vec;
  rep(i,n) {
    string s;
    int x;
    cin>>s>>x;
    mount[x]=s;
    vec.push_back(x);
  }
  sort(vec.begin(),vec.end(),greater<int>()); 
  cout<<mount[vec[1]]<<endl;
}