index=Hash.new{|word,page| word[page] = []}
while line =gets do
	word,page= line.split(" ")
	page =page.to_i
	index[word]<<page
end
p index
index.each{|word,page|page.sort!}
index2=index.sort

index2.each{|key,value|
	puts key
	puts value.join(" ")
}