#include #include #include template std::vector vec(int len, T elem) { return std::vector(len, elem); } void next(int& x, int& vx, int h) { x += vx; while (true) { if (x < 0) { x = -x; } else if (x > h) { x = h * 2 - x; } else { break; } vx = -vx; } } void solve() { int h, w, d, gx, gy, sx, sy, vx, vy; std::cin >> h >> w >> d >> gx >> gy >> sx >> sy >> vx >> vy; int g = std::abs(std::gcd(vx, vy)); d *= g, vx /= g, vy /= g; auto visited = vec(h + 1, vec(w + 1, 0)); for (int t = 0; t <= d; ++t) { if (sx == gx && sy == gy) { std::cout << "Hit\n"; return; } if (visited[sx][sy] == 4) break; ++visited[sx][sy]; next(sx, vx, h), next(sy, vy, w); } std::cout << "Miss\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int q; std::cin >> q; while (q--) solve(); return 0; }