import sys from math import gcd input = sys.stdin.readline ceil = lambda a, b: (a + b - 1) // b Q = int(input()) for _ in range(Q): W, H, D, Mx, My, Hx, Hy, Vx, Vy = map(int, input().split()) g = gcd(Vx, Vy) Ux, Uy = Vx // g, Vy // g X, Y = Hx + Ux, Hy + Uy ct = 1 while not (X % (2 * W) == Hx and Y % (2 * H) == Hy) and ceil(ct, g) <= D: if X % (2 * W) in {Mx, 2 * W - Mx} and Y % (2 * H) in {My, 2 * H - My}: print('Hit') break X += Ux Y += Uy ct += 1 else: print('Miss')