#include <iostream>
using namespace std;
int main(){
	static int count[1001] = {0};
	int n,d;
	char tmp;
	while(cin >> n >> tmp >> d){
		count[n]++;
	}
	for(int i=1;i<1001;i++){
		if(count[i] > 1){
			cout << i << " " << count[i] << endl;
		}
	}
	return 0;
}