from collections import defaultdict

n = int(input())
d = defaultdict(int)
for i in range(n):
    idx, val = map(int, input().split())
    d[idx] += val
for key in sorted(d):
    print("{} {}".format(key, d[key]))