dic = {}
n = int(input())
while True:
try:
line = input()
tmp = line.split()
index = int(tmp[0])
value = int(tmp[1])
if index in dic:
dic[index] += value
else:
dic[index] = value
except:
break
for k, v in sorted(dic.items()):
print(f'{k} {v}') 
京公网安备 11010502036488号