class Test
  @@h = Hash.new{|index,key| index[key] = []}
  def dataIntoHash(data)
    n,m = data.split
   	m2 = m.to_i
    @@h[n] << m2
  end
  
  def hashSort
      @@h.each{|key, value| value.sort!}
      @@h = @@h.sort
  end
  
  def dataOut
    @@h.each{|key, value| 
    puts key + "\n"
    puts value.join(" ")
    }
  end
end


tes = Test.new
while data = gets
  tes.dataIntoHash(data)
end
tes.hashSort
tes.dataOut