#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
	pair<int, int> biz[10000];
	int n, d;
	
	fill(biz, biz + 10000, pair<int, int>(0, 0));
	while (scanf("%d,%d", &n, &d) != EOF){
		if (biz[n].first > d) biz[n].first = -1;
		else if (biz[n].first != -1) biz[n].first = d;
		biz[n].second++;
	}
	for (int i = 1; i < 10000; i++){
		if (biz[i].first == -1){
			printf("%d %d\n", i, biz[i].second);
		}
	}
	
	return 0;
}