dic = {} n = int(input()) while True: try: line = input() tmp = line.split() index = int(tmp[0]) value = int(tmp[1]) if index in dic: dic[index] += value else: dic[index] = value except: break for k, v in sorted(dic.items()): print(f'{k} {v}')
dic = {} n = int(input()) while True: try: line = input() tmp = line.split() index = int(tmp[0]) value = int(tmp[1]) if index in dic: dic[index] += value else: dic[index] = value except: break for k, v in sorted(dic.items()): print(f'{k} {v}')