#include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) using namespace std; typedef long long ll; int exgcd(int a, int b, int &g) { int u = 1, v = 0; while(b) { int t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } g = a; return u; } ll crt(ll a1, ll n1, int a2, int n2, ll &resn) { int t, g; t = exgcd(n1 % n2, n2, g); if((a1 - a2) % g != 0) return -1; int m = n2 / g; int h = (a2 - a1) / g % m * t % m; if(h < 0) h += m; resn = n1 * m; return a1 + n1 * h; } int red(int x, int y) { int z = x % y; if(z < 0) z += y; return z; } int main() { int Q; scanf("%d", &Q); rep(ii, Q) { int W[2], D, M[2], H[2], V[2]; cin >> W[0] >> W[1] >> D >> M[0] >> M[1] >> H[0] >> H[1] >> V[0] >> V[1]; int s; exgcd(abs(V[0]), abs(V[1]), s); bool ans = false; rep(m, 4) { ll t = 0, n = 1; rep(k, 2) { int w = W[k] * 2, x = red(((m >> k & 1) ? 2 * W[k] - M[k] : M[k]) - H[k], w), a, g; a = exgcd(red(V[k] / s, w), w, g); if(x % g != 0) t = -1; w /= g; a = (ll)red(a, w) * (x / g) % w; if(t != -1) t = crt(t, n, a, w, n); } ans |= t != -1 && t <= (ll)D * s; } puts(ans ? "Hit" : "Miss"); } return 0; }