#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, l, m[1100];
  char s[1100][34];
  scanf("%d", &n);
  map<string, int> mp, mp2;
  for (i = 0; i < n; i++) {
    scanf("%s%d", s[i], &m[i]);
    mp[s[i]] += m[i];
  }
  string name;
  int max = 0;
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    if (it->second > max) max = it->second;
  }
  for (i = 0; i < n; i++) {
    mp2[s[i]] += m[i];
    if (mp[s[i]] >= max && mp2[s[i]] >= max) break;
  }
  puts(s[i]);
  scanf("%*d");
}
