#include #include using namespace std; int main() { int n; cin>>n; map<int,int> m; map<int,int>::iterator it; while(n--) { int a,b; cin>>a>>b; it = m.find(a); if(it != m.end()) { m[a] = it->second + b; }else{ m[a]=b; } } for(it=m.begin();it!=m.end();it++) { cout<first<<" "<second<<endl; } }