q = int(input()) for _ in range(q): I = int(input()) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) f = True if A[0] * A[2] + A[1] * A[3] > I: f = False if B[0] * B[2] + B[1] * B[3] > I: f = False if not f: print("No") continue ama0 = I - A[0] * A[2] - A[1] * A[3] ama1 = I - B[0] * B[2] - B[1] * B[3] if ama0 >= A[0] or ama0 >= A[1] or ama1 >= B[0] or ama1 >= B[1]: print("No") continue a0, b0 = A[:2] a1, b1 = B[:2] if a0 * b1 == a1 * b0: print("Yes") continue if a0 * b1 > a1 * b0: a0, a1, b0, b1 = a1, a0, b1, b0 A, B = B, A if (a1 * b0 - a0 * b1) * A[2] < I * (b0 - b1) and (a1 * b0 - a0 * b1) * B[2] > I * (b0 - b1): print("No") else: print("Yes")