#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 k = 1; for (i64 i = 0; i < 3; i++) { k *= l.z - v[i].z; } for (i64 i = 0; i < 3; i++) { u[i] = Pose{(-l.x * v[i].z + l.z * v[i].x) * (k / (l.z - v[i].z)), (-l.y * v[i].z + l.z * v[i].y) * (k / (l.z - v[i].z)), 0}; } assert(k > 0); i128 s = (u[0].x - u[2].x) * (u[1].y - u[2].y) - (u[1].x - u[2].x) * (u[0].y - u[2].y); if (s < 0) s = -s; mint ans = mint(s); ans /= 2; ans /= mint(k).pow(2); cout << ans.val() << "\n"; } }