#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        map<int,int>mp;
        while(n--)
        {
            int first,second;
            cin>>first>>second;
            if(mp.count(first))
            {
                int v=mp[first]+second;
                mp[first]=v;
            }
            else
            {
                mp[first]=second;
            }
        }
        //sort(mp.begin(),mp.end());
        map<int,int>::iterator iter;
        iter=mp.begin();
        while(iter!=mp.end())
        {
            cout<<iter->first<<" "<<iter->second<<endl;
            iter++;
        }
    }
    return 0;
}