#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; #define mt make_tuple int gcd(int a, int b){ return b?gcd(b, a%b):a; } int vis[2][2][15][15], W, H, D, MX, MY, HX, HY, VX, VY, mami[3][3][15][15]; bool solve(){ MEM(vis, 0); MEM(mami, 0); if(VX < 0)VX = -VX, MX = W - MX, HX = W - HX; if(VY < 0)VY = -VY, MY = H - MY, HY = H - HY; int g = gcd(VX, VY); VX /= g; VY /= g; int lim = (int)(min((ll)g*D+1, 1000)); rep(s, 2)rep(t, 2)mami[s][t][s ? W - MX : MX][t ? H - MY : MY] = 1; int s=0, t=0, x=HX, y=HY; rep(i, lim){ if(vis[s][t][x][y]++)return false; if(mami[s][t][x][y])return true; x += VX; y += VY; s = (s + x / W) % 2; t = (t + y / H) % 2; x %= W; y %= H; } return false; } int main(){ int Q; cin >> Q; while(Q--){ scanf("%d%d%d%d%d%d%d%d%d", &W, &H, &D, &MX, &MY, &HX, &HY, &VX, &VY); puts(solve() ? "Hit" : "Miss"); } }