#include #include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using mint = atcoder::modint998244353; struct pos{ ll x,y,z; }; mint volume(pos a,pos b,pos c,pos d){ a.x-=d.x;b.x-=d.x,c.x-=d.x; a.y-=d.y;b.y-=d.y,c.y-=d.y; a.z-=d.z;b.z-=d.z,c.z-=d.z; ll ans=0; ans+=a.x*b.y*c.z; ans+=a.y*b.z*c.x; ans+=a.z*b.x*c.y; ans-=a.x*b.z*c.y; ans-=a.y*b.x*c.z; ans-=a.z*b.y*c.x; return mint(abs(ans))/6; } int main(){ int t; cin >> t; while(t--){ vectora(4); for(auto&[x,y,z]:a)cin >> x >> y >> z; mint v=volume(a[0],a[1],a[2],a[3]); v*=a[3].z; v*=a[3].z; v*=a[3].z; v/=a[3].z-a[0].z; v/=a[3].z-a[1].z; v/=a[3].z-a[2].z; v*=3; v/=a[3].z; cout << v.val() << endl; } return 0; }