hash=Hash.new
while str=gets do
   str=str.chomp.split(' ')
   str[1]=str[1].to_i
   if hash.key?(str[0])
      hash[str[0]].push(str[1])
   else
      hash[str[0]]=Array.new
      hash[str[0]].push(str[1])
   end
end
hash.sort.each do |key,value|
   puts key
   flag=false
   value.sort.each do |out|
      print ' 'if flag
      flag=true
      print out
   end
   puts
end