#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i ++ )
#define N 100010

struct Node
{
  string s;
  int x;
  bool operator< (const Node &W) const{
    return x > W.x;
  }
}a[N];

int main(void)
{
  int n; cin >> n;
  rep(i, n) cin >> a[i].s >> a[i].x;
  sort(a, a + n);
  cout << a[1].s << endl;
  return 0;
}

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n;
    cin >> n;

    vector<pair<int, string>> ts(n);
    REP(i, n) {
        string tmp_s;
        int tmp_i;

        cin >> tmp_s >> tmp_i;
        ts[i] = make_pair(tmp_i, tmp_s);
    }

    sort(ALL(ts), greater<>());

    cout << ts[1].second << endl;

    return 0;
}
