#include using namespace std; #define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++) #define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++) #define all(n) (n).begin(),(n).end() typedef long long ll; typedef vector Vi; typedef vector VVi; typedef pair Pii; typedef vector VPii; typedef complex P; int canDiv(int a,int b){ if( b == 0 ) return a == 0; else return 1. * a / b >= 0; } int main(){ int Q; cin >> Q; while(Q--){ int W,H,D,Mx,My,Hx,Hy,Vx,Vy; cin >> W >> H >> D >> Hx >> Hy >> Mx >> My >> Vx >> Vy; for(int i = -50 ; i < 50 ; i++){ for(int j = -50 ; j < 50 ; j++){ int ox = j * W; int oy = i * H; // int mx = j % 2 ? W - Mx; // int my = i % 2 ? H - My; int hx = (j % 2 ? W - Hx : Hx)+ox; int hy = (i % 2 ? H - Hy : Hy)+oy; // cout << (hx - Mx) % Vx << " " << (hy - My) % Vy << endl; // if(canDiv(hy-My,Vy)) cout << "OK" << canDiv(hx-Mx,Vx) << " " << canDiv(hy-My,Vy) << "|" << hy-My << "|" << i << " " << j << endl; P I = P(hx,hy) - P(Mx,My); P V(Vx,Vy); if( abs(I)/abs(V) > D + 1e-4 ) continue; P IE = I / abs(I); P VE = V / abs(V); // cout << (I*conj(V)).imag() << endl; if( abs(IE-VE) <= 1e-9 ){ // cout << abs(I)/abs(V) << "|" << D << " " << i << "|" << I << endl; // cout << I << "(" << P(hx,hy) << "(((" << i << " " << j << ")))" << "|||" << P(Mx,My) << "||||" << V << "|" << abs(I)/abs(V) << endl; // cout << VE << " " << IE << "|" << abs(I)/abs(V) << "|" << D << endl; cout << "Hit" << endl; goto exit; } } } cout << "Miss" << endl; exit:; } }