#include <stdio.h>
int main() {
int a, b;
int num;
int arrid[500]={0};
int arrva[500]={0};
scanf("%d", &num);
int count=0;
while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case
// 64 位输出请用 printf("%lld") to
int find=0;
for(int j=0;j<count;j++)
{if(arrid[j]==a){arrva[j]+=b;find=1;}}
if(!find){arrid[count]=a;arrva[count]=b;count++;}
}
//对arrid进行冒泡排序
for(int n=0;n<count;n++){
for(int i=0;i<count-1;i++){
if(arrid[i]>arrid[i+1]){
int temp_id;
temp_id=arrid[i];
arrid[i]=arrid[i+1];
arrid[i+1]=temp_id;
int temp_va;
temp_va=arrva[i];
arrva[i]=arrva[i+1];
arrva[i+1]=temp_va;
}
}
}
for (int k = 0; k <count; k++) {
printf("%d %d\n", arrid[k], arrva[k]);
}
return 0;
}