import sys
number = sys.stdin.readline().strip()
json_1 = {}
for line in range(int(number)):
a = sys.stdin.readline().strip()
b = int(a.split()[0])
c = int(a.split()[1])
if b in json_1.keys():
json_1[b] = json_1[b] + c
else:
json_1[b] = c
for i in sorted(json_1):
print(i, json_1[i])



京公网安备 11010502036488号