#include #include using namespace std; using i32 = int; using i64 = long long; using i128 = __int128_t; using f64 = double; using p2 = pair; using el = tuple; using mint = atcoder::modint998244353;; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); _main(); } struct Pose { i128 x, y, z; static Pose input() { i64 xx, yy, zz; cin >> xx >> yy >> zz; return Pose{xx, yy, zz}; } }; void _main() { i64 tt; cin >> tt; for (;tt--;) { vector v(3), u(3); for (i64 i = 0; i < 3; i++) { v[i] = Pose::input(); } Pose l = Pose::input(); i128 a = l.z - v[0].z; i128 b = l.z - v[1].z; i128 c = l.z - v[2].z; i128 k = a * b * c; vector kk = {a, b, c}; for (i64 i = 0; i < 3; i++) { u[i] = Pose{-l.x * v[i].z + l.z * v[i].x, -l.y * v[i].z + l.z * v[i].y, 0}; } i128 s = ((u[0].x * c - u[2].x * a) * (u[1].y * c - u[2].y * b) - (u[1].x * c - u[2].x * b) * (u[0].y * c - u[2].y * a)); if (s < 0) s = -s; mint ans = mint(s); ans /= 2; ans /= a; ans /= b; ans /= c; ans /= c; cout << ans.val() << "\n"; } }