#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int temp;
	int id[1001]={},index=0;
	while(scanf("%d,%d",&index,&temp)!=EOF){
		id[index]++;
		//printf("id[%d]=%d\n",index,id[index]);
	}
	for(int i=0;i<1001;i++){
		if(id[i]>1)
		printf("%d %d\n",i,id[i]);
	}
}
