import math Q = int(input()) for _ in range(Q): w, h, d, mx, my, hx, hy, vx, vy = map(int, (input().split())) hit = [[0 for _ in range(w+1)] for _ in range(h+1)] k = math.gcd(abs(vx), abs(vy)) d *= k vx //= k vy //= k for i in range(min(d + 1, 257 * 4)): dx = abs(hx + i * vx) dy = abs(hy + i * vy) dx %= 2 * w if(dx > w): dx = 2 * w - dx dy %= 2 * h if(dy > h): dy = 2 * h - dy hit[dy][dx] = 1 if hit[my][mx] == 1: print("Hit") else: print("Miss")