#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

int main (){
    unsigned N;
    while(cin>>N){
        int index,value;
        map<int,int> mapi;
        while(cin>>index>>value){
            
            auto rsultpair = mapi.insert(pair<int,int>(index,value));
            if(!rsultpair.second){
                mapi[index]=mapi[index]+value;
            }
            
            N--;
            if(N==0)break;
        }
        auto it = mapi.cbegin();
        while(it!=mapi.cend()){
            cout<<it->first<<' '<<it->second<<endl;
            it++;
        }
        
        
    }
    
}