import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int[int] cnt;
	foreach (line; stdin.byLine) {
		if (!line.length) continue;
		cnt[line.split(",").map!(to!int)[0]]++;
	}
	foreach (key; cnt.keys.sort) {
		if (cnt[key] < 2) continue;
		writeln(key, " ", cnt[key]);
	}
}