n_records = int(input()) res_dic = {} for i in range(n_records): key, value = map(int, input().split()) if key not in res_dic: res_dic[key] = value else: res_dic[key] += value res_dict_sorted = dict(sorted(res_dic.items(), key=lambda x: x[0])) for key, value in res_dict_sorted.items(): print(f"{key} {value}") #for index in sorted(res_dic): # print(f"{index} {res_dic[index]}")