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 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 = f(L[0], L[1], A[0], A[1], L[2], A[2]) bx, by = f(L[0], L[1], B[0], B[1], L[2], B[2]) cx, cy = f(L[0], L[1], C[0], C[1], L[2], C[2]) ans0 = -((bx-ax) * (cy-ay) - (cx-ax) * (by-ay)) ans0 %= mod ans0 = ans0 * pow(2, -1, mod) % mod print(ans0)