#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main() {
int n;
int a,b;
map<int,int> h;
while(cin>>n)
{
while(n--)
{
cin>>a>>b;
if(h.find(a)==h.end())
h.insert(make_pair(a,b));
else h[a]+=b;
}
for(auto it=h.begin();it!=h.end();it++)
{
cout<<(*it).first<<" "<<(*it).second<<endl;
}
}
}
// 64 位输出请用 printf("%lld")



京公网安备 11010502036488号