import sys input_data = sys.stdin.read().split() n = int(input_data[0]) D = {} for i in range(1,n*2,2): index = int(input_data[i]) value = int(input_data[i+1]) if index in D.keys(): D[index] = D[index] + value else: D[index] = value for index in sorted(D.keys()): print(index,D[index])