#include using namespace std; using namespace atcoder; using ll = long long; bool solve(){ ll W, H, D, Mx, My, Hx, Hy, Vx, Vy, g, gx, gy, Dx, Dy; cin >> W >> H >> D >> Mx >> My >> Hx >> Hy >> Vx >> Vy; g = gcd(Vx, Vy); Vx /= g, Vy /= g, D *= g; gx = gcd(Vx, 2 * W), gy = gcd(Vy, 2 * H); Vx /= gx, Dx = 2 * W / gx; Vy /= gy, Dy = 2 * H / gy; for(int i = 0; i < 4; i++){ ll mx = (i & 1? 1: -1) * Mx - Hx; ll my = (i & 2? 1: -1) * My - Hy; if(mx % gx != 0 || my % gy != 0)continue; mx /= gx, my /= gy; (mx *= inv_mod(Vx, Dx)) %= Dx; (my *= inv_mod(Vy, Dy)) %= Dy; auto res = crt({mx, my}, {Dx, Dy}); if(res.second == 0)continue; if(res.first <= D)return true; } return false; } int main(){ int t; cin >> t; while(t--){ cout << (solve() ? "Hit" : "Miss") << '\n'; } }