sub f{my($c,$x,$y,$z)=@_;$$c[$y][$x]//=do{$z+=$-=f($c>>1,$x,$_)+f($c+1>>1,$_,$y)-$z for@m;$z}}$n=<>-1;@m=0..<>-1;@1=map[glob],<>;map{//;$%+=$-=f($n,$_,$')-$%for@m}@m;print$%