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

int main() {
    int n;
    cin >> n;
    map<int,int> input;
    while(n--){
        int i, j;
        cin >> i >> j;
        input[i] += j;
    }
    for(auto x : input) cout << x.first << ' '<< x.second << endl;
}