my %ih = map { my $k = $_; $k => [ grep { $h{$_} eq $k } keys %h ] } keys {reverse %h};