#include <iostream>
#include <map>
using namespace std;

#define mp make_pair

map<int,int> dict;

void solve() {
	int id, day;
	char camma;
	while (cin>>id>>camma>>day) {
		if (dict.count(id) == 0) {
			dict.insert(mp(id,1));
		} else {
			dict[id] += 1;
		}
	}

	map<int,int>::iterator it = dict.begin();
	while (it != dict.end()) {
		if (it->second >= 2)
			cout<<it->first<<" "<<it->second<<endl;
		it++;
	}
}

int main(int argc, const char *argv[]) {
	solve();
	return 0;
}