$;=$"; @d=(-2,-2,-1,+1,+2,+2,+1,-1); $n=<>; for(0..$n-1){ ($x[$_],$y[$_])=($x,$y)=glob<>; $p{$x,$y}=1<<$_; for$j(0..7){ $k{$x-$d[$j+6&7],$y-$d[$j]}=1; } } for(0..$n-1){ delete $k{$x[$_],$y[$_]}; } $b{0}=0; for(keys%k){ %a=%b; $k=$k{$_}; ($x,$y)=glob; for$j(0,2,4,6){ $p=0; for(0,1){ $p|=$p{$x+$d[$j+6&7^$_],$y+$d[$j^$_]}; } if($p){ for(keys%a){ $b{$_|$p}=$a{$_}+1 if !defined $b{$_|$p} || $b{$_|$p}>$a{$_}+1; } } } } print $b{(1<<$n)-1}//-1;