hash_tab = {}
while True:
try:
num_list = input().split(' ')
except:
break
if len(num_list) == 1:
...
else:
key = int(num_list[0])
value = int(num_list[1])
if hash_tab.get(key):
hash_tab[key] += value
else:
hash_tab[key] = value
keys = sorted(hash_tab) # 注意题目描述,升序排列键值
for key in keys:
print(key, hash_tab[key])