def get_ans(li):
ans=dict()
for i in range(int(li[0])):
key,val=li[i+1].split(' ')
key,val=int(key),int(val)
ans[key]=ans.get(key,0)+val
ans= sorted(ans.items(), key=lambda d:d[0])
return ans
if __name__=='__main__':
import sys
lines = []
while True:
line = sys.stdin.readline().strip()
if line == "":
break
lines.append(line)
res=get_ans(lines)
for i in res:
print("{} {}".format(i[0], i[1]))