l=[]
m=[]
while a = gets
  a = a.split(/ /)
  a[0] = a[0].to_s
  a[1] = a[1].to_i
  p = m.index(a[0])
  if p == NIL
    l.push([a[0],[a[1]]])
    m.push(a[0])
  else
    l[p][1].push(a[1])
  end
end
l.sort!
for i in 0..l.length-1
  puts l[i][0],l[i][1].sort!*" "
end