import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines import math import itertools def inv(a, mod): b, x, y=mod, 1, 0 while b: t=a//b a-=t*b x-=t*y a, b=b, a x, y=y, x return x%mod q=int(readline()) for _ in range(q): w, h, d, mx, my, hx, hy, vx, vy=map(int, readline().split()) if vy==0: w, h, mx, my, hx, hy, vx, vy=h, w, my, mx, hy, hx, vy, vx if vx<0: vx=-vx hx, mx=w-hx, w-mx if vy<0: vy=-vy hy, my=h-hy, h-my a=2*h*vx b=2*w*vy g=math.gcd(a, b) a//=g b//=g for cx, cy in itertools.product((mx, 2*w-mx), (my, 2*h-my)): c=(cx-hx)*vy-(cy-hy)*vx if c%g!=0: continue c//=g r=inv(a, b)*c%b y=-2*h*r-cy+hy if (y+2*h*b-1)//(2*h*b)<=(y+d*vy)//(2*h*b): print("Hit") break else: print("Miss")