my @b = list_reduce { 0, $a || $b ne $_->[-1] ? $b : () } 1, @a;