def f(x0, y0, x1, y1, z0, z1): x = x0 + (x1-x0) * z0 * pow(z0-z1, -1, mod) % mod x %= mod y = y0 + (y1-y0) * z0 * pow(z0-z1, -1, mod) % mod y %= mod return x, y, x0 + (x1-x0) * z0 / (z0-z1), y0 + (y1-y0) * z0 / (z0-z1) mod = 998244353 for _ in range(int(input())): A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) L = list(map(int, input().split())) ax, ay, ax0, ay0 = f(L[0], L[1], A[0], A[1], L[2], A[2]) bx, by, bx0, by0 = f(L[0], L[1], B[0], B[1], L[2], B[2]) cx, cy, cx0, cy0 = f(L[0], L[1], C[0], C[1], L[2], C[2]) if (bx0-ax0) * (cy0-ay0) - (cx0-ax0) * (by0-ay0) < 0: ans = -((bx-ax) * (cy-ay) - (cx-ax) * (by-ay)) else: ans = (bx-ax) * (cy-ay) - (cx-ax) * (by-ay) ans = ans * pow(2, -1, mod) % mod print(ans)