dic={}
while pair = STDIN.gets
  pair.chomp!
  word, page = pair.split(" ")
  if dic.has_key?(word) then
    dic[word] += ' '+page
  else
    dic[word] = page
  end
    
end

dic.keys.sort.each do |k|
  puts k
  pages = dic[k]
  pages = pages.split(" ").map { |item| item.to_i }
  pages = pages.sort.join(" ")
  puts pages 
end