/* Author : Anurag Bhatt 
 * Date   : 2021-05-15 17:32:03
 */
#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi; 
typedef vector<pi> vpi;

#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define bk back()
#define pb push_back
#define ins insert
#define del erase
#define inf INT_MAX
#define db cout << "here" << endl;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define nl endl
const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
mt19937 rng; // or mt19937_64
template<class T> bool ckmin(T& a, const T& b) { 
    return b < a ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << h; if (sizeof...(t)) cerr << ", ";
    DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
const int MX = 200002;
const int INF = MX+MX;  
vector<int> adj[MX];
void solve() {
    int n;
    cin >> n;
    string name[n];
    int height[n];
    int hei[n];
    F0R(i,n) {
        cin >> name[i];
        cin >> height[i];
        hei[i]=height[i];
    }
    sort(height,height+n);
    F0R(i,n) {
        if(hei[i]==height[n-2]) {
            cout << name[i] << endl;
            return;
        }
    }
}

int main() {
    int t = 1;
    //cin >> t; //comment if there is only one test - case
    for(int i = 1; i <= t ; i++) {
        solve();
    }
}
    

/*if ((double) ((double)(clock() - cl)/(double)CLOCKS_PER_SEC)>1.85) {break;}*/
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define double long double
#define ft first
#define sc second
#define pb push_back
#define booost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
#define all(x) (x).begin(),(x).end()
#define file(x) freopen(string(string((x)) + ".in").c_str(), "r", stdin); freopen(string(string((x)) + ".out").c_str(), "w", stdout);
#define GG cout << " OPA " << '\n';

using namespace std;
using namespace __gnu_pbds;
typedef pair <int, int> pi;
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1e5 + 5;
const int K = 1e3 + 5;
const int P = 37;
const int INF = 1e18;
const double d_INF = 2000000000.0;
const double EPS = 1e-20;
const int MOD = 1e9 + 7;
const int LOG = 25;

void solve() {
    int n;
    cin >> n;
    vector <pair <int, string> > v;
    for (int i = 1; i <= n; i ++) {
        string s;
        int x;
        cin >> s >> x;
        v.pb({x, s});
    }
    sort(all(v), greater <pair <int, string> > ());
    cout << v[1].sc << '\n';
}

main () {
    int test = 1;
    booost;
//    cin >> test;
    while (test --) {
        solve();
    }
}
