#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; ll gcd(ll a, ll b) { if (b == 0) return abs(a); else return gcd(b, a % b); } int main() { int Q; cin >> Q; while (Q--) { int W, H, D, mx, my, hx, hy, vx, vy; cin >> W >> H >> D >> mx >> my >> hx >> hy >> vx >> vy; if (vx < 0) { vx *= -1; mx = W - mx; hx = W - hx; } if (vy < 0) { vy *= -1; my = H - my; hy = H - hy; } int d = gcd(vx, vy); if (d == 0) { vx = (vx ? 1 : 0); vy = (vy ? 1 : 0); } vx /= d; vy /= d; bool flag = false; for (int i = 0; i < min(D, 1000); i++) { int x = mx, y = my; if (hx / W % 2) x = W - x; if (hy / H % 2) y = H - y; if (hx % W == x && hy % H == y) { flag = true; break; } hx += vx; hy += vy; } cout << (flag ? "Hit" : "Miss") << endl; } }