hash = {}
while gets != nil
  word, page = gets.split
  if hash[word] == nil
    hash[word] = [page.to_i]
  else
    hash[word] << page.to_i
  end
end
hash.values.each {|item| item.sort!}
hash = Hash[hash.sort]
hash.each {|k, v| puts k, v.join(" ")}