#include using namespace std; typedef long long int ll; typedef pair P; #define repi(i,a,b) for(ll i=a;i=0;i--) #define MOD 1000000007 //debug #define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<> Q; bool ans[Q]; rep(q, Q) ans[q] = false; rep(q, Q){ ll W, H, D, Mx, My, Hx, Hy, Vx, Vy; cin >> W >> H >> D >> Mx >> My >> Hx >> Hy >> Vx >> Vy; ll g = gcd(Vx, Vy); Vx /= g; Vy /= g; D *= g; bool visited[W+1][H+1][4]; rep(w, W+1) rep(h, H+1) rep(i, 4) visited[w][h][i] = false; while(D--){ Hx = (Hx + Vx + W * 20) % (2 * W); if(Hx > W){ Vx = -Vx; Hx = 2 * W - Hx; } Hy = (Hy + Vy + H * 20) % (2 * H); if(Hy > H){ Vy = -Vy; Hy = 2 * H - Hy; } // cout << Hx << " " << Hy << endl; if((Hx == Mx) && (Hy == My)) ans[q] = true; ll dir = (Vx > 0) * 2 + (Vy > 0); if(visited[Hx][Hy][dir]) break; visited[Hx][Hy][dir] = true; } } rep(q, Q){ if(ans[q]) puts("Hit"); else puts("Miss"); } return 0; }