#include <iostream>
#include <map>
using namespace std;
int main() {
int n;
int key, value;
cin >> n;
map<int, int> res;
for (int i = 0; i < n; ++i) {
cin >> key >> value;
res[key] += value;
}
for (auto &[key, value] : res) {
cout << key << " " << value << endl;
}
}

京公网安备 11010502036488号