# 解答生成用 def point_shadow(Z, P): A, B, C = P return Fraction(Z * A, Z - C), Fraction(Z * B, Z - C) def triangle_area(U, V, W): UVx = V[0] - U[0]; UVy = V[1] - U[1] UWx = W[0] - U[0]; UWy = W[1] - U[1] return abs(UVx * UWy - UVy * UWx) / 2 def solve(): triangle = [list(map(int, input().split())) for _ in range(3)] X, Y, Z = map(int, input().split()) # 平行移動 for point in triangle: point[0] -= X point[1] -= Y S = triangle_area(*[point_shadow(Z, point) for point in triangle]) return S.numerator * pow(S.denominator, -1, Mod) % Mod #================================================== from fractions import Fraction import sys input = sys.stdin.readline write = sys.stdout.write Mod = 998244353 T = int(input()) write("\n".join(map(str, [solve() for _ in range(T)])))