n = int(input()) dic = dict() for _ in range(n): index, val = [int(each) for each in input().split()] if index not in dic: dic[index] = val else: dic[index] += val for i in sorted(dic): print('%d %d'%(i,dic[i]))