my %h = ();
foreach(split(/\r?\n/, $data)){
 my($k,$v) = split(/ +/, $_);
 $h{$v} += $k-0;
}

foreach(sort {$a-$b} keys %h){
 print "$h{$_} $_\n";
}