import sys from fractions import gcd def solve(): def extgcd(a, b): s, t = 1, 0 u, v = 0, -1 while b: a, (q, b) = b, divmod(a, b) s, u = u, s - q * u t, v = v, t - q * v return (s, t) input = sys.stdin.readline Q = int(input()) for _ in range(Q): W, H, D, x2, y2, x1, y1, vx, vy = map(int, input().split()) if vx < 0: x1, x2, vx = W - x1, W - x2, -vx if vy < 0: y1, y2, vy = H - y1, H - y2, -vy if vx == 0 or vy == 0: if vy == 0: x1, y1 = y1, x1 x2, y2 = y2, x2 vx, vy = vy, vx hit = False for y3 in [y2, 2 * H - y2]: if y3 < y1: y3 += 2 * H if vx == 0: if x1 == x2: tn = (y3 - y1) td = vy if D * td >= tn: hit = True else: for x3 in [x2, 2 * W - x2]: if x3 < x1: x3 += 2 * W a = 2 * W * vy b = 2 * H * vx c = vy * (x1 - x3) - vx * (y1 - y3) g = gcd(a, b) if c % g != 0: continue a, b, c = a // g, b // g, c // g s, t = extgcd(a, b) s *= c t *= c q = min(s // b, t // a) s -= b * q t -= a * q assert(s - b < 0 or t - a < 0) tn = (x3 - x1 + 2 * W * s) td = vx if D * td >= tn: hit = True print("Hit" if hit else "Miss") solve()