#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	
	int W[1002]={};
	int R,D;

	while((scanf("%d,%d",&R,&D))!=EOF){
		W[R]++;
	}
	for(int i=0;i<1002;i++){
		if(W[i]>1)cout<<i<<" "<<W[i]<<endl;
	}
	return 0;
}