def solve(X, Y, D, Mx, My, Hx, Hy, Vx, Vy): if Vx == 0: return can_hit(Y, D, My, Hy, Vy) if Vy == 0: return can_hit(X, D, Mx, Hx, Vx) x0, y0 = Hx, Hy dx, dy = Vx, Vy d = 0 while d < D: if hit(Mx, My, Hx, Hy, Vx, Vy, D): return True if d and returned(x0, y0, dx, dy, Hx, Hy, Vx, Vy): return False Hx, Hy, Vx, Vy, d = move(Hx, Hy, Vx, Vy, d, X, Y) return False def can_hit(Z, D, Mz, Hz, Vz): t1 = (Mz - Hz) / Vz if t1 >= 0: return t1 <= D if Vz > 0: Hz = 2 * Z - Hz else: Hz = - Hz t2 = - (Mz - Hz) / Vz return t2 >= 0 and t2 <= D def hit(tx, ty, x, y, dx, dy, D): ddx = tx - x ddy = ty - y if ddx * dy - ddy * dx: return False t = ddx/dx return t >= 0 and t <= D def returned(x0, y0, dx, dy, Hx, Hy, Vx, Vy): if dx != Vx or dy != Vy: return False return (x0 - Hx) * dy - (y0 - Hy) * dx == 0 def move(Hx, Hy, Vx, Vy, d, X, Y): if Vx > 0: if Vy > 0: tmp = (Y-Hy)*Vx - (X-Hx)*Vy if tmp >= 0: # 右辺にぶつかる d = (X - Hx)/Vx Hx = 2*X - Hx Vx = -Vx elif tmp <= 0: # 上辺にぶつかる d = (Y - Hy)/Vy Hy = 2*Y - Hy Vy = -Vy else: tmp = (0-Hy)*Vx - (X-Hx)*Vy if tmp >= 0: # 下辺にぶつかる d = -Hy/Vy Hy = -Hy Vy = -Vy elif tmp <= 0: # 右辺にぶつかる d = (X - Hx)/Vx Hx = 2*X - Hx Vx = -Vx else: if Vy > 0: tmp = (Y-Hy)*Vx - (0-Hx)*Vy if tmp >= 0: # 上辺にぶつかる d = (Y - Hy)/Vy Hy = 2*Y - Hy Vy = -Vy elif tmp <= 0: # 左辺にぶつかる d = (0 - Hx)/Vx Hx = - Hx Vx = -Vx else: tmp = (0-Hy)*Vx - (0-Hx)*Vy if tmp >= 0: # 左辺にぶつかる d = -Hx/Vx Hx = -Hx Vx = -Vx elif tmp <= 0: # 下辺にぶつかる d = -Hy/Vy Hy = -Hy Vy = -Vy return Hx, Hy, Vx, Vy, d if __name__ == '__main__': Q = int(input()) for q in range(Q): X, Y, D, Mx, My, Hx, Hy, Vx, Vy = map(int, input().split()) if solve(X, Y, D, Mx, My, Hx, Hy, Vx, Vy): print('Hit') else: print('Miss')