#include #include using namespace std; using namespace atcoder; constexpr int mod = 998244353; void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } template struct SegmentTree { int n,kk; vector dat; SegmentTree() {} SegmentTree(int N,int K,vectorA) { n = 1; while(n < N) { n *= 2; } kk = K; dat.resize(2*n-1); for(int i = 0; i < N; i++) { vectortmp(K); tmp[A[i]] = 1; tmp[0]++; dat[n-1+i] = tmp; } for(int i = n-2; i >= 0; i--) { if(dat[i*2+2].size() == 0) { dat[i] = dat[i*2+1]; continue; } if(dat[i*2+1].size() == 0) { dat[i] = dat[i*2+2]; continue; } vectorres = convolution(dat[i*2+1],dat[i*2+2]); for(int j = K; j < res.size(); j++) { mpl(res[j-K],res[j]); } res.resize(K); dat[i] = res; } } T query(int a, int b, int k, int l, int r) { if(r <= a || b <= l) return {}; if(a <= l && r <= b) return dat[k]; T vl = query(a, b, 2*k+1, l, (l+r)/2); T vr = query(a, b, 2*k+2, (l+r)/2, r); if(vr.size() == 0) return vl; if(vl.size() == 0) return vr; vectornxt = convolution(vl,vr); for(int j = kk; j < nxt.size(); j++) { mpl(nxt[j-kk],nxt[j]); } nxt.resize(kk); return nxt; } T query(int a,int b) {//[a,b) return query(a,b,0,0,n); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,M,K; cin >> N >> M >> K; vectorA(N); for(int i = 0; i < N; i++) { cin >> A[i]; } SegmentTree>Seg(N,K,A); for(int i = 0; i+M <= N; i++) { cout << (Seg.query(i,i+M)[0]+mod-1)%mod << endl; } }