#include <cstdio>
#include <map>
#include <utility>
using namespace std;
typedef pair<int, int> P;

int main()
{
	map<int, P> biz;
	int id, day;
	
	while (scanf("%d,%d", &id, &day) != EOF){
		biz[id].first++;
		if (biz[id].second != -1 && biz[id].second < day){
			biz[id].second = day;
		}
		else {
			biz[id].second = -1;
		}
	}
	for (map<int, P>::iterator i = biz.begin(); i != biz.end(); i++){
		if (i->second.second == -1) printf("%d %d\n", i->first, i->second.first);
	}
	
	return 0;
}