#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; typedef vector vl; typedef pair pll; typedef vector > vpll; typedef vector vs; typedef long double ld; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } templateT gcd_positive(T x, T y) { return y == 0 ? x : gcd_positive(y,x%y); } templateT gcd(T x, T y) { return gcd_positive(abs(x), abs(y)); } template inline T floordiv(T x, T y) { T q = x / y, r = x % y; return q - ((r!=0) & ((r<0) ^ (y<0))); } int main() { const char *Hit = "Hit", *Miss = "Miss"; int Q; scanf("%d", &Q); rep(ii, Q) { int W, H, D, Mx, My, Hx, Hy, Vx, Vy; scanf("%d%d%d%d%d%d%d%d%d", &W, &H, &D, &Mx, &My, &Hx, &Hy, &Vx, &Vy); int Vg = gcd(Vx, Vy); Vx /= Vg, Vy /= Vg; bool ok = false; rep(t, W*H) { int xx = Hx + Vx * t, yy = Hy + Vy * t; int a = floordiv(xx, W), b = floordiv(yy, H); int x = a % 2 == 0 ? xx - a * W : W - (xx - a * W); int y = b % 2 == 0 ? yy - b * H : H - (yy - b * H); // cerr << t << ": " << x << ", " << y << endl; if(x == Mx && y == My && (t + Vg - 1) / Vg <= D) ok = true; } puts(ok ? Hit : Miss); } return 0; }