#include <iostream>
#include <map>
#include <iterator>
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));
	for(mp=m.begin();mp!=m.end();mp++)
	{
		int tmp=mp->first;
		int sum=distance(m.lower_bound(tmp),m.upper_bound(tmp));
		if(sum>=2) cout << tmp << ' ' << sum << endl ;
		mp=m.upper_bound(tmp);
	}
}