while 1:
    try:
        m = int(input())
        res = dict.fromkeys(list(range(m)), 0)
        for i in range(m):
            k, v = map(int, input().split(' '))
            res[k] += v
        for k, v in res.items():
            if v:
                print(k, v)
    except:
        break

c62a855f7f510f22621d2634afbffa6173a40300
<mask token>

while 1:
    try:
        m = int(input())
        res = dict.fromkeys(list(range(m)), 0)
        for i in range(m):
            k, v = map(int, input().split(' '))
            res[k] += v
        for k, v in res.items():
            if v:
                print(k, v)
    except:
        break
