#include <iostream>
#include <map>
using namespace std;
int main()
{
	multimap<int,int> m;
	multimap<int,int>::iterator mp;
	int a,b; char ch;
	while(cin>>a>>ch>>b) m.insert(pair<int,int>(a,b));
	int tmp=m.begin()->first; int sum=0;
	for(mp=m.begin();mp!=m.end();mp++)
	{
		if(tmp==mp->first) sum++;
		else
		{
			if(sum>=2) cout << tmp << ' ' << sum << endl ;
			sum=1; tmp=mp->first;
		}
	}
	if(mp==m.end() && sum>=2) cout << tmp << ' ' << sum << endl;
}