n, a = [], {} while True: try: n.append(tuple(input().split(' '))) except: break n.pop(0) n = sorted(n, key=lambda x:int(x[0])) for i in n: a[i[0]] = 0 for i in n: a[i[0]] += int(i[1]) for k, v in a.items(): print(k, v)