// Arup Guha
// 6/13/2024
// Solution to Kattis Problem: Besta gjofin
// https://open.kattis.com/problems/bestagjofin

using namespace std;
#include <bits/stdc++.h>

int main() {

    // Get # of friends
    int n;
    cin >> n;

    // Set first to best.
    string res, tmp;
    int best, gift;
    cin >> res >> best;

    // Read rest.
    for (int i=0; i<n-1; i++) {

        // Get this gift.
        cin >> tmp >> gift;

        // Got a better answer.
        if (gift > best) {
            best = gift;
            res = tmp;
        }
    }

    // Ta da!
    cout << res << endl;
    return 0;
}
