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

int main() {
    int n;
    map<int, int> mtb;
    map<int, int>::iterator it;
    int a, b;

    cin >> n;

    while (n && cin >> a >> b) { // 注意 while 处理多个 case
        it = mtb.find(a);
        if (it != mtb.end())
        {
            mtb[a] = it->second + b;
        }
        else{
            mtb[a] = b;
        }
        n--;
    }

    for (auto i = mtb.begin(); i != mtb.end(); i++)
    {
        cout << i->first << " " << i->second << endl;
    }
    
}
// 64 位输出请用 printf("%lld")