#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int gcd(int a, int b){ while(b != 0){ int tmp = a % b; a = b; b = tmp; } return a; } bool solve() { int w, h, n, mx, my, x, y, vx, vy; cin >> w >> h >> n >> mx >> my >> x >> y >> vx >> vy; int g = gcd(abs(vx), abs(vy)); n *= g; vx /= g; vy /= g; n = min(n, (w + 1) * (h + 1) * 4); while(--n >= 0){ x += vx; y += vy; while((vx < 0 && x <= 0) || (vx > 0 && x >= w)){ if(x <= 0) x = -x; else x = 2 * w - x; vx *= -1; } while((vy < 0 && y <= 0) || (vy > 0 && y >= h)){ if(y <= 0) y = -y; else y = 2 * h - y; vy *= -1; } if(x == mx && y == my) return true; } return false; } int main() { int q; cin >> q; while(--q >= 0){ if(solve()) cout << "Hit" << endl; else cout << "Miss" << endl; } return 0; }