@g=@h=100;$h[$m=$_]&&map{$m&1<<$_ or$h[$k=$m|1<<$_]+=$-=($b=$g[$k]=$g[$m]+($@[$_]<0)*100)-($-=$b-$h[$m]-$@[$_])-$h[$k]}0..$#@for 0..2**<>,@@=glob<>;print$h[-1]