gets.to_i.times{ w,h,d,mx,my,hx,hy,vx,vy=gets.split.map(&:to_i) gcd=vx.abs.gcd(vy.abs) vx/=gcd vy/=gcd puts (0..[d*gcd,1024].min).any?{|i| (ansx=hx+vx*i)==(wn=ansx/w)*w+(wn%2==0?mx:(w-mx))&& (ansy=hy+vy*i)==(hn=ansy/h)*h+(hn%2==0?my:(h-my)) }?"Hit":"Miss" }