#include using namespace std; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int q; cin >> q; while (q--) { int w, h, d, mx, my, hx, hy, vx, vy; cin >> w >> h >> d >> mx >> my >> hx >> hy >> vx >> vy; int g = gcd(abs(vx), abs(vy)); vx /= g; vy /= g; d *= g; // 状態が(W+1)*(H+1)*4しかない int cx, cy; for (int t = 1; t <= min(d, (h+1)*(w+1)*4); t++) { cx = abs(hx + t * vx); cy = abs(hy + t * vy); cx %= 2 * w; if (cx > w) cx = 2 * w - cx; cy %= 2 * h; if (cy > h) cy = 2 * h - cy; if (cx == mx && cy == my) break; } if (cx == mx && cy == my) cout << "Hit" << endl; else cout << "Miss" << endl; } return 0; }