require 'scanf'
hash = Hash.new
while str=STDIN.gets
    str=str.chomp
    name,page=str.scanf("%s %d")
    hash[name] = [] if not hash.has_key?name
    hash[name].push(page)
end

keys = hash.keys.sort
for k in keys do
    print k,"\n"
    l = hash[k].sort
    for i in 0..l.length-1 do
        print l[i]
        print " " if i<l.length-1
    end
    print "\n"
end