# https://yukicoder.me/problems/no/3437 MOD = 998244353 def projection(l, a): x = (l[2] * (a[0] - l[0]), l[2] - a[2]) y = (l[2] * (a[1] - l[1]), l[2] - a[2]) return x, y def substruct(b, a): """ b - a""" v0 = b[0] * a[1] - a[0] * b[1] v1 = b[1] * a[1] return v0, v1 def calc_vec(b_proj, a_proj): return substruct(b_proj[0], a_proj[0]), substruct(b_proj[1], a_proj[1]) def outer_product(v0, v1): v0_x, v0_y = v0 v1_x, v1_y = v1 w0 = v0_x[0] * v1_y[0], v0_x[1] * v1_y[1] w1 = v1_x[0] * v0_y[0], v1_x[1] * v0_y[1] return substruct(w0, w1) def solve(a, b, c, l): a_proj = projection(l, a) b_proj = projection(l, b) c_proj = projection(l, c) vec_ab = calc_vec(b_proj, a_proj) vec_ac = calc_vec(c_proj, a_proj) o = outer_product(vec_ab, vec_ac) if o[0] == 0: return 0 elif o[0] < 0: o = -o[0], o[1] ans = o[0] % MOD, o[1] % MOD ans = (ans[0] * pow(ans[1], MOD - 2, MOD)) % MOD ans *= pow(2, MOD - 2, MOD) ans %= MOD return ans def main(): T = int(input()) answers = [] for _ in range(T): a = tuple(map(int, input().split())) b = tuple(map(int, input().split())) c = tuple(map(int, input().split())) l = tuple(map(int, input().split())) ans = solve(a, b, c, l) answers.append(ans) for ans in answers: print(ans) if __name__ == "__main__": main()