#define MD 998244353 ll@n,@m,@k,@a[n]; Mint s[m+2][k]; s[0][0]=s[m+1][0]=1; rep(j,n-m+1){ ll r=j%m; if(r){ rep(i,k){ s[r][i]=s[r-1][i]+s[r-1][(i+a[m-1+j])%k]; } }else{ rrep(h,m){ rep(i,k){ s[h+1][i]=s[h+2][i]+s[h+2][(i+a[j+h])%k]; } } } wt(sum[Mint][i,0,k](s[r][i]*s[r+1][(-i)%%k])-1); }