organize-contest
Source: hackerearth
Difficulty: EASY

Campus Ambassador has organized a Coding Contest in his college. Contest has multiple rounds, in each round a participant may gain or lose few points. At the end, there is only one participant with the maximum points. In the course of the contest, the number of points is written in the line as

"name points", where name is the participant's name and points is, the number of points is gained.

If the point is negative, this means the participant has lost in the round. If two partcipants have the maximum number of points, then winners is the one who scored at least m points first.

Intially each participant has 0 points. It's guranteed that at the end of the game at least one participant has a positive number of points.

Input

The first line contains an integer N, total number of rounds. Then follow N lines, containing information about the rounds in "name points" format in chronological order.

Output

Print the Name of the winner of the Contest.

Constraints

1 ≤ N ≤ 1000

'name' is the string of lower case letter 1 ≤ |name| ≤ 32

-1000 ≤points ≤ 1000

SAMPLE INPUT
3
mini 3
rini 5
mini 2

SAMPLE OUTPUT
rini

Explanation

After the contest both rini and mini have scored same points that is 5 ,
but rini scored 5 points first, hence the winner.


import operator

topper = ''
topscore = 0
t = int(input())
scores = {}

for i in range(t):
	inp = input().split(' ')
	name = inp[0]
	score = int(inp[1])
	if name in scores:
		scores[name] += score
	else:
		scores[name] = score
	
	temp = max(scores, key=scores.get)
	tc = scores[temp]
	toppers = [key for key in scores if scores[key] == tc]
	if len(toppers) == 1:
		topper = temp 
	if len(toppers) == 1:
		topper = toppers[0]
print(topper)


t=eval(input())
c=[];
d={};
g=0;
p=[]
for i in range(t):
	v=input();
	p=v.split();
	f=p[0];
	n=int(p[1])
	if d.get(f,-1)!=-1:
		d[f]+=n;
	else:
		c.append(f);
		d[f]=n;
	if g==0:
		k=d[f];
		m=f;
		g=1;
	elif g==1 and d[f]>k:
		k=d[f];
		m=f;
#for item in c:
#    print d[item]
print(m);
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(eval(input()))
p=0
d={}
b=[]
while t:
	t-=1
	a=input().split()
	if a[0] in d:
		d[a[0]]=d[a[0]]+int(a[1])
	else:
		d[a[0]]=int(a[1])
	b.append(a[0])
p=max(d.values())
a=[]
for i in b:
    if p==d[i] and i not in a:
        a.append(i)
for i in b[::-1]:
    if len(a)==1:
        break
    if i in a:
        a.remove(i)
print((a[0]))




d,dd = {},{}
a,b = [],[]
z = eval(input())
for i in range(z):
	st = input().split()
	nm,n = st[0], int(st[1])
	a.append(nm)
	b.append(n)
	try:
		d[nm]+=n
	except:
		d[nm]=n

mx = max(d.values())

for i in range(z):
	try:
		dd[a[i]]+=b[i]
	except:
		dd[a[i]]=b[i]
	if dd[a[i]]==mx:
		print(a[i])
		break