module AOJ_Volume0105;

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

int main()
{
	string f[101];
	string[string] m;
	string s;
	string res[];

	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(" ");
		m[_s[0]] ~= _s[1];
		m[_s[0]] ~= " ";

		bool flag = true;
		foreach(j;0..res.length)
		{
			if(res[j] == _s[0]) flag = false;
		}

		if(flag) res ~= _s[0];
	}
	res.sort;

	foreach(i;0..res.length)
	{
		res[i].writeln;
		m[res[i]] = m[res[i]][0..$-1];
		string[] temp = m[res[i]].split(" ");
		int a[];
		foreach(j;0..temp.length)
		{
			a ~= temp[j].to!int;
		}

		a.sort;
		foreach(j;0..a.length)
		{
			if(j == a.length-1)
			{
				a[j].writeln;
			}
			else
			{
				write(a[j]," ");
			}
		}
	}
	return 0;
}