#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; } int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { auto get_p = [](array a, array l) { int q = l[2] - a[2], p = l[2]; // * p/q mint pq = mint(p) / q; return pair(l[0] + (a[0] - l[0]) * pq, l[1] + (a[1] - l[1]) * pq); }; array a, b, c, l; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; rep(i, 3) cin >> c[i]; rep(i, 3) cin >> l[i]; auto get_sgn = [](auto a, auto b, auto c, auto l) { rep(i, 3) a[i] -= l[i]; rep(i, 3) b[i] -= l[i]; rep(i, 3) c[i] -= l[i]; // | a b c | ll det = (ll)a[0] * b[1] * c[2] + (ll)a[1] * b[2] * c[0] + (ll)a[2] * b[0] * c[1] - (ll)a[1] * b[0] * c[2] + (ll)a[2] * b[1] * c[0] + (ll)a[0] * b[2] * c[1]; return det > 0; }; auto ap = get_p(a, l); auto bp = get_p(b, l); auto cp = get_p(c, l); auto px = bp.first - ap.first, py = bp.second - ap.second; auto qx = cp.first - ap.first, qy = cp.second - ap.second; mint ans = (px * qy - py * qx) / 2; if (get_sgn(a, b, c, l)) ans *= -1; cout << ans.val() << '\n'; } }