#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int count;
    cin>>count;
    map<int, int> times;
    for(int i = 0; i < count; i++){
        int first, second;
        cin>>first>>second;
        times[first] += second;    
    }
    for (auto record: times){
        cout<<record.first<<" "<<record.second<<endl;
    }
    return 0;
}