list = Hash.new(0)

loop{
  break if (input = gets.chomp) == ""
  input = input.split
  list[input[0]] = Array.new() if list[input[0]] == 0
  list[input[0]].push(input[1].to_i)
}

list.sort.each do |key,val|
  print("#{key}\n")
  print("#{val.sort.join(" ")}\n")
end