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

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