sub f { my%s;%r=@_;map{$m{$_}={map{$m{$_}||={};$_=>1}@{$r{$_}}}}keys%r; reverse sort{($a->{$b})-($b->{$a})}keys%m; }