while True:
    try:
        d={}
        n=eval(input())
        for i in range(n):
            a,b=input().split()
            a=eval(a)
            if a not in d:
                d[a]=b
            else:
                d[a]=str(eval(d[a])+eval(b))
        for c in sorted(d.keys()):
            print(c,d[c])
    except:
        break