#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<fstream>
constexpr int Mod = 998244353;
using namespace std;

struct Node {
    string name;
    int h;
};

bool comp(Node a, Node b) {
    return a.h > b.h;
}

int main() {
    int N;
    cin >> N;
    string s;
    int he;
    vector<Node> q;
    for (int i = 1; i <= N; i++) {
        cin >> s >> he;
        q.push_back(Node{ s,he });
    }
    sort(q.begin(), q.end(), comp);
    cout << q[1].name << endl;
    
    

    return 0;
}
#include <algorithm>
#include <bitset>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define rd1(a) cin >> (a)
#define rd2(a, b) cin >> (a) >> (b)
#define rd3(a, b, c) cin >> (a) >> (b) >> (c)
#define rd4(a, b, c, d) cin >> (a) >> (b) >> (c) >> (d)

#define init1(a) int (a); rd1((a));
#define init2(a, b) int (a), (b); rd2((a), (b));
#define init3(a, b, c) int (a), (b), (c); rd3((a), (b), (c));
#define init4(a, b, c, d) int (a), (b), (c), (d); rd4((a), (b), (c), (d));

#define repa(i, a, b) for (auto i = (a); i <= (b); ++i)
#define repd(i, a, b) for (auto i = (a); i >= (b); --i)
#define forz(i, n) for (auto i = 0; i < n; ++i)
#define fori(i, n) for (auto i = 1; i <= n; ++i)
#define fore(i, t) for (auto &&i : t)

#define all(x) (x).begin(), (x).end()
#define repmin(x, y) x = min(x, y)
#define repmax(x, y) x = max(x, y)
#define ll long long
#define lll __int128
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(t) ((int)(t).size())
#define vi vector<int>
#define vs vector<string>
#define vd vector<ld>
#define inf 1000000100
#define neginf -1000000100
#define DBG(var)                                                               \
  cerr << "[" << __LINE__ << "] " << #var << " = " << (var) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &s, pair<T1, T2> &t) {
  return s << "(" << t.first << "," << t.second << ")";
}

template <typename T>
void read_vec(T& v, size_t n) {
  forz(i, n) { typename T::value_type t; cin >> t; v.pb(t); }
}

template <typename T>
void write_vec(T& v) {
  forz(i, sz(v)) { cout << v[i] << " \n"[i == sz(v) - 1]; }
}

template <typename T> ostream &operator<<(ostream &s, vector<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T> ostream &operator<<(ostream &s, set<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T> ostream &operator<<(ostream &s, unordered_set<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T, typename S>
ostream &operator<<(ostream &s, map<T, S> &m) {
  s << "{ ";
  for (auto i = m.begin(); i != m.end(); i++)
    s << "(" << i->first << " -> " << i->second << ") ";
  s << "}";
  return s;
}

// globals
//

void preproc() {
  // add any preprocessing valid for all tests here
  //
}

void single(int testId) {
  // add code here
  //
  init1(n);
  vector<pair<int, string>> tt;
  forz(i, n) {
      string s; int t;
      cin >> s >> t;
      tt.pb({t, s});
  }
  sort(all(tt), greater<pair<int,string>>());
  cout << tt[1].second << "\n";
}

void multiple() {
  // multiple tests in single file
  int T;
  cin >> T;
  for (auto t = 1u; t <= T; t++)
    single(t);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  preproc();

  single(0);
  //multiple();

  return 0;
}
