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

typedef map<int, pair<int, int> > pair_map;

int main()
{
	pair_map biz;
	int n, d;
	int maxi = 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++;
		if (maxi < n) maxi = n;
	}
	for (int i = 1; i <= maxi; i++){
		if (biz.find(i) != biz.end() && biz[i].first == -1){
			printf("%d %d\n", i, biz[i].second);
		}
	}
	
	return 0;
}