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

void main(){
    int[][string] dic;
    while(1){
        auto line=readln;
        if(!line.length)break;
        auto inp=line.split;
        dic[inp[0]]~=inp[1].to!int;
    }
    foreach(key;dic.keys.array.sort()){
        key.writeln;
        dic[key].array.sort().map!(to!string).join(" ").writeln;
    }
}