#coding: utf-8
#AOJ vol1-0105

list = Hash.new(0)

while (input = gets.chomp) != ""
  input = input.split
  list[input[0]] = Array.new() if list[input[0]] == 0
  list[input[0]].push(input[1].to_i)
end

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