n = int(input())
records = {}

for _ in range(n):
    x, y = map(int, input().split())
    if x in records:
        records[x] += y
    else:
        records[x] = y

for x in sorted(records.keys()):
    print(x, records[x])