#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> a, b;
  int i, j, m, k[1001];
  string a1[1001];
  cin >> i;
  for (j = 0; j < i; j++) {
    cin >> a1[j] >> k[j];
    a[a1[j]] = a[a1[j]] + k[j];
  }
  for (j = 0; j < i; j++) {
    m = max(m, a[a1[j]]);
  }
  int A = 0;
  for (j = 0;;) {
    if (a[a1[j]] < m || (b[a1[j]] += k[j]) < m) {
      j++;
    } else {
      break;
    }
  }
  cout << a1[j];
  return 0;
}
