dic = {}
a = int(input())
for a in range(a):
lista =str(input()).split(" ")
a,b = int(lista[0]),int(lista[1])
if a not in dic:
dic[a] = b
else:
dic[a] = dic[a] + b
for k,v in sorted(dic.items()):
print(f'{k} {v}')