def gcd(a,b): if min(a,b) == 0: return max(a,b) while b: a,b = b,a%b return a Q = int(raw_input()) for loop in xrange(Q): W,H,D,Mx,My,Hx,Hy,Vx,Vy = map(int,raw_input().split()) d = gcd(abs(Vx),abs(Vy)) D *= d; Vx /= d; Vy /= d; x,y = Hx,Hy xy = set([(x,y)]) once = set([]) for t in xrange(D): x += Vx; y += Vy if not (0 <= x <= W): while not (0 <= x <= W): x = -x if x < 0 else 2*W-x Vx = -Vx if not (0 <= y <= H): while not (0 <= y <= H): y = -y if y < 0 else 2*H-y Vy = -Vy if (x,y) in xy: if (x,y) in once: break once.add((x,y)) xy.add((x,y)) print "Hit" if (Mx,My) in xy else "Miss"