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

void main(){

    int[][string] dic;
    string[] list;
    list ~= "";
    while(true){
	string s = readln();
	if(stdin.eof())break;
	auto s1 = s.split();
	dic[s1[0]] ~= to!int(s1[1]);
	list ~= s1[0];
    }
    list.sort;
    for(int i=1;i<list.length;i++){
	if(list[i-1] != list[i]){
	    writeln(list[i]);
	    writeln(dic[list[i]].sort.to!(string[]).join(" "));
	}
    }
}