#include <iostream> #include <map> using namespace std; int main() { int n; cin >> n; map<int, int> m; int a, b; while(cin >> a >> b) { m[a] += b; } for(auto it: m) { cout << it.first << " " << it.second << endl; } return 0; }