#include #include #include using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 1e8 typedef long long ll; int gcd(int a, int b) { return (b == 0) ? a : gcd(b,a%b); } int main() { int i, j, q; cin >> q; rep (i,q) { int w, h, d, mx, my, hx, hy, vx, vy; int x, y; cin >> w >> h >> d >> mx >> my >> hx >> hy >> vx >> vy; x = hx; y = hy; vx = vx / gcd(abs(vx),abs(vy)); vy = vy / gcd(abs(vx),abs(vy)); for (j = -1; j < min(1000,d) && (x != mx || y != my); j++) { x += vx + 30*w; y += vy + 30*h; x %= 2*w; y %= 2*h; if (x > w) { x = 2*w - x; vx = -vx; } if (y > h) { y = 2*h - y; vy = -vy; } } if (j != min(1000,d)) cout << "Hit" << endl; else cout << "Miss" << endl; } return 0; }