#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i VI; typedef vector VVI; bool visited[32][32]; int main() { int q; cin>>q; FOR(i,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); memset(visited , 0 , sizeof(visited)); int g = __gcd(abs(vx), abs(vy)); vx /= g; vy /= g; d *= g; bool ok = false; FOR(t,d){ hx += vx; hy += vy; hx = (hx + w * 1024) % (2 * w); hy = (hy + h * 1024) % (2 * h); if(visited[hy][hx]) break; visited[hy][hx] = true; if((hx == mx || hx == (2 * w - mx)) && (hy == my || hy == (2 * h - my))){ ok = true; break; } } puts(ok ? "Hit": "Miss"); } return 0; }