if true then
  fh=STDIN
else
  fh=open("in0105.txt")
end

h = Hash.new
while fh.gets do
  f =$_.chomp.split
  w =f[0] 
  p = f[1].to_i
  if h.has_key?(w) then
    h[w].push(p)
  else
    h[w]=[p]
  end
end

h.keys.sort.each{|w|
  puts w
  puts h[w].sort.map{|x|x.to_s}.join(" ")
}