#include using namespace std; using namespace atcoder; using ll = long long; bool solve(){ ll W, H, D, Mx, My, Hx, Hy, Vx, Vy, g; cin >> W >> H >> D >> Mx >> My >> Hx >> Hy >> Vx >> Vy; g = gcd(Vx, Vy); Vx /= g, Vy /= g, D *= g; for(int i = 0; i < 4; i++){ ll mx = Mx, my = My; if(i & 1)mx = - mx; if(i & 2)my = - my; mx -= Hx; my -= Hy; ll gx = gcd(Vx, 2 * W), gy = gcd(Vy, 2 * H); if(mx % gx != 0 || my % gy != 0)continue; mx /= gx, my /= gy; (mx *= inv_mod(Vx / gx, 2 * W / gx)) %= 2 * W / gx; (my *= inv_mod(Vy / gy, 2 * H / gy)) %= 2 * H / gy; auto res = crt({mx, my}, {2 * W / gx, 2 * H / gy}); 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'; } }