#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	map<int, int> c;
	int a, b;
	while (scanf("%d,%d", &a, &b) != EOF)
	{
		if (c.count(a) > 0)
			++c[a];
		else
			c.insert(make_pair(a, 1));
	}
	for (map<int, int>::iterator it = c.begin(); it != c.end(); ++it)
	{
		if (it->second >= 2)
			printf("%d %d\n", it->first, it->second);
	}

	return 0;
}