num = int(input())
dic = {}
for i in range(num):
line = input().split(' ')
key = int(line[0])
value = int(line[1])
dic[key] = dic.get(key,0) + value
for key in sorted(dic):
print(key,dic.get(key))1.循环将输入的值存入字典中
2.按key将dic排序,依次取出

num = int(input())
dic = {}
for i in range(num):
line = input().split(' ')
key = int(line[0])
value = int(line[1])
dic[key] = dic.get(key,0) + value
for key in sorted(dic):
print(key,dic.get(key))1.循环将输入的值存入字典中
2.按key将dic排序,依次取出