#include<bits/stdc++.h>
using namespace std;
const int maxn=5e6+5,mod=998244353;
int fc[maxn],iv[maxn];
int read(){
int x=0,y=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')y=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*y;
}
inline int add(int x){
if(x>=mod)x-=mod;
return x;
}
inline int sub(int x){
if(x<0)x+=mod;
return x;
}
int power(int x,int b){
int ans=1;
while(b){
if(b&1)ans=1ll*ans*x%mod;
x=1ll*x*x%mod;
b>>=1;
}
return ans;
}
void pre1(){
fc[0]=1;
for(int i=1;i<=5e6;i++)fc[i]=1ll*fc[i-1]*i%mod;
iv[5000000]=power(fc[5000000],mod-2);
for(int i=5e6-1;i>=0;i--)iv[i]=1ll*iv[i+1]*(i+1)%mod;
return ;
}
int C(int n,int m){
return 1ll*fc[n]*iv[m]%mod*iv[n-m]%mod;
}
int down(int n,int m){
return 1ll*fc[n]*iv[n-m]%mod;
}
int h[maxn];
void pre2(int n,int m,int l,int s){
int pai=1;
for(int i=1;i<=s;i++)pai=1ll*pai*sub(1ll*n*m%mod*l%mod-1ll*(n-i)*(m-i)%mod*(l-i)%mod)%mod;
h[s]=power(pai,mod-2);
for(int i=s-1;i>=1;i--)h[i]=1ll*h[i+1]*sub(1ll*n*m%mod*l%mod-1ll*(n-i-1)*(m-i-1)%mod*(l-i-1)%mod)%mod;
return ;
}
int main(){
int T;
T=read();
pre1();
while(T--){
int n,m,l,k,s;
n=read();m=read();l=read();k=read();
s=min(n,min(m,l));
pre2(n,m,l,s);
int op=1,res=0;
for(int i=k;i<=s;i++){
res=add(res+1ll*op*C(i,k)%mod*down(n,i)%mod*down(m,i)%mod*down(l,i)%mod*h[i]%mod);
op=mod-op;
}
printf("%d\n",res);
}
return 0;
}剪贴板
剪贴板 2nanj1zg
剪贴板信息
剪贴板信息
- 收录
- 更新