h=Hash.new 0 gets $<.each_slice(3){|_,m,s|s.split.map{|t|h[t]+=m[/ .*/].to_i}} puts h.sort_by{|k,v|[-v,k]}.map{|s|s*" "}[0,10]