grep sub { (1 == grep defined, @_) or ($_[0] ne $_[1]) }->(values @{$h->{$_}}['O','C']), keys %$h;