#include<iostream> #include<map> using namespace std; int main() { int n,index,value; map<int int=""> imap; while(cin>>n) { for(int i=0;i<n i="" cin="">>index; cin>>value; if(imap.count(index)) imap[index]+=value; else imap.insert(make_pair(index,value)); } for(map<int int="">::iterator it=imap.begin();it!=imap.end();it++) { cout<<it->first<<" "<<it->second<<endl; } } //system("pause"); return 0; } </it-></it-></int></n></int></map></iostream>