#include using namespace std; int Q; bool vis[4][16][16]; int X,Y,D,Mx,My,Hx,Hy,Vx,Vy; int gcd(int a,int b){return b?gcd(b,a%b):a;} main() { cin>>Q; for(;Q--;) { cin>>X>>Y>>D>>Mx>>My>>Hx>>Hy>>Vx>>Vy; int g=gcd(Vx>0?Vx:-Vx,Vy>0?Vy:-Vy); Vx/=g; Vy/=g; D*=g; for(int r=0;r<4;r++)for(int i=0;i<=X;i++)for(int j=0;j<=Y;j++)vis[r][i][j]=false; int x=Hx,y=Hy,r=0; for(;D--&&!vis[r][x][y];) { vis[r][x][y]=true; x+=r&1?-Vx:Vx; y+=r&2?-Vy:Vy; while(x<0||x>X) { if(x<0)x=-x,r^=1; else if(x>X)x=X-(x-X),r^=1; } while(y<0||y>Y) { if(y<0)y=-y,r^=2; else if(y>Y)y=Y-(y-Y),r^=2; } } bool ans=false; for(int r=0;r<4;r++)ans|=vis[r][Mx][My]; cout<<(ans?"Hit":"Miss")<