# 方法1
n = int(input())
dic = {}
for _ in range(n):
    line = input().split()
    index = int(line[0])
    value = int(line[1])
    if index not in dic:
        dic[index] = value
    else:
        dic[index] += value

for k, v in sorted(dic.items()):
    print(k, v)


# 方法2
# 如果dic中存在index,则使用index对应的value值;否则使用设定的默认值0
# dic[index] = dic.get(index, 0) + value