#include using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define PQ priority_queue #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it) #define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it) template bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } template T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- template T mod(T x, T y) { return (x % y + y) % y; } template void setmod(T & x, T y) { x = mod(x, y); } int main() { int q; cin >> q; inc(qq, q) { LL w, h, d, mx, my, hx, hy, vx, vy; cin >> w >> h >> d >> mx >> my >> hx >> hy >> vx >> vy; int f[30][30]; inc(i, 30) { inc(j, 30) { f[i][j] = 0; } } LL dd = abs(gcd(vx, vy)); d *= dd; vx /= dd; vy /= dd; //cout << "d: " << d << endl; //cout << "v: " << vx << " " << vy << endl; f[hx][hy] = 1; inc(i, d) { // cout << hx << " " << hy << endl; hx += vx; setmod(hx, w * 2); hy += vy; setmod(hy, h * 2); // (hx += vx) %= w * 2; // (hy += vy) %= h * 2; if(! setmax(f[hx][hy], 1)) { break; } } int g = 0; setmax(g, f[ mx][ my]); setmax(g, f[w * 2 - mx][ my]); setmax(g, f[ mx][h * 2 - my]); setmax(g, f[w * 2 - mx][h * 2 - my]); cout << (g == 0 ? "Miss" : "Hit") << "\n"; f[ mx][ my] += 2; f[w * 2 - mx][ my] += 2; f[ mx][h * 2 - my] += 2; f[w * 2 - mx][h * 2 - my] += 2; string s = ".aO@"; /* dec(y, h * 2) { inc(x, w * 2) { cout << s[f[x][y]] << " "; } cout << endl; } cout << endl; */ } return 0; }