#include <bits/stdc++.h>
using namespace std;

int main() {
    int tmp=0, tmp1=0;
    map<int, int> map;//key有序且不可重复
    cin>>tmp;
    while(cin>>tmp){
        cin>>tmp1;
        if(map.find(tmp)!=map.end()){//找到则值叠加
            map[tmp] += tmp1; 
        }else{
            map.insert(make_pair(tmp, tmp1));//否则产生新的键值对
        } 
    }
    for(auto i:map){
        cout<<i.first<<' '<<i.second<<'\n';
    }
    return 0;
}