<>;for$l(<>){$$_=<+$l>for a..j;$h%$_|$i%$_||($h/=-$_,$i/=-$_,$c*=-$_)for-13..-2;print[1..($c<900?$c:900)]~~sub{$a-$d-abs$a-($f+=$h)%(2*$a)|$b-$e-abs$b-($g+=$i)%(2*$b)}?Miss:Hit,$/}