n=int(input()) dic=dict() for _ in range(n): k,v=list(map(lambda x:int(x),input().split())) if k in dic: dic[k]+=v else: dic[k]=v keys=sorted(dic.keys()) res=[(key,dic[key]) for key in keys] for item in res: k,v=item print(k,v)