import std.stdio, std.string, std.conv, std.algorithm;

void main() {
	string str;
	uint[][string] dictionary;
	while (true) {
		str = readln;
		if (str.length == 1) break;
		auto tmp = str.split;
		if (tmp.length < 2) break;
		dictionary[tmp[0]] ~= to!uint(tmp[1]);
	}
	struct Word {
		string str;
		uint[] pages;
	}
	Word[] words;
	foreach (k, v; dictionary) {
		v = v.sort;
		words ~= Word(k, v);
	}
	words.sort!((a,b) => a.str < b.str);
	foreach (w; words) {
		w.str.writeln;
		foreach (p; w.pages) {
			p.write;
			write(' ');
		}
		writeln;
	}
}