#include<bits/stdc++.h> using namespace std; int main() { int n; while( ~scanf("%d",&n) ) { map<int,int> mp; while( n-- ) { int key,value; scanf("%d%d",&key, &value ); mp[key]+=value; } for( auto it : mp ) { printf("%d %d\n", it.first, it.second ); } } return 0; }