my %h = ();
while($data =~ /(\d+) (\d+)/g){
 $h{$2} += $1-0;
}
for(sort {$a-$b} keys %h){
 print "$h{$_} $_\n";
}