<>; @d=sort{$b-$a}glob<>; ($x,$y)=glob<>; if($x==0&&$y==0){ print 0; exit; } $z=abs($x)+abs($y); if(grep$z==$_,@d){ print 1; exit; } ($e0)=grep{$_%2==0}@d; ($e1)=grep{$_%2==1}@d; if( $z%2 ? $z<=$e1*2 : $z<=$e1+$e2 || $z<=$e0*2 ) { print 2; exit; } print -1;