#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
	int a,b,ta[1000000];
int main(){

	char kasu;
	while(scanf("%d%c%d",&a,&kasu,&b)!=EOF){
		ta[a]++;
	}
	
	for(int i=0;i<100000;i++){
	if(ta[i]>=2)cout<<i<<" "<<ta[i]<<endl;
	}
	return 0;
}