#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int sum[1111], cnt, po[1111], Sum[1111];
char s[1111][1111], ss[1111][1111];
int a[1111];
int find(char *s) {
  if (mp[s]) return mp[s];
  mp[s] = ++cnt;
  strcpy(ss[cnt], s);
  return cnt;
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int mx = -1000000000;
    for (int i = 1; i <= n; i++) {
      scanf("%s%d", s[i], &a[i]);
      int id = find(s[i]);
      sum[id] += a[i];
    }
    for (int i = 1; i <= cnt; i++) mx = max(mx, sum[i]);
    for (int i = 1; i <= n; i++) {
      int id = find(s[i]);
      Sum[id] += a[i];
      if (Sum[id] >= mx && sum[id] >= mx) {
        puts(s[i]);
        break;
      }
    }
  }
}
