class Newhash < Hash
  def [](key)
    self[key] = Array.new if !has_key?(key)
    super(key)
  end
end
def main
  hsh = Newhash.new
  while arg = gets
    arg = arg.split(" ")
    hsh[arg[0]] << arg[1].to_i
  end  
  hsh.keys.sort.each{|key|
    puts key, hsh[key].sort.join(" ")
  }
end
main