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

int main() {
    int n;
    cin >> n;
    map<int,int> m;
    for (int i = 0; i < n; ++i){
        int a,b;
        cin >> a >> b;
        m[a] += b;
    }
    for (auto i :m) { 
        cout << i.first << ' ' << i.second << endl;
    }
}