#include using namespace std; using ll = long long; #define all(p) p.begin(),p.end() #define rep(i,a,b) for(int i=(int)a;i<(int)b;i++) const int mod=998244353; int main(){ int N,K; cin>>N>>K; vector C(N),D(N); rep(i,0,N) cin>>C[i]; rep(i,0,N) cin>>D[i]; vector dp1(K+1); vector dp2(K+1,1); rep(i,0,K){ dp2[i]%=mod; rep(j,0,N){ int ind=i+C[j]; int val=D[j]+dp1[i]; if(ind<=K){ if(dp1[ind]==val) dp2[ind]+=dp2[i]; else if(dp1[ind]