list = Hash.new{|index,key|
  index[key] = []
}

while input = gets do
  break if input.chomp == ""
  input = input.split
  list[input[0]] << (input[1].to_i)
end

list.sort.each do |key,val|
  puts key
  puts val.sort.join(" ")
end