#include #include using namespace std; const long long MOD = 998244353; template struct sliding_window_aggregation{ function f; T E; stack> fr, bk; sliding_window_aggregation(function f, T E): f(f), E(E){ } void push(T x){ if (fr.empty()){ fr.push(make_pair(x, x)); } else { fr.push(make_pair(x, f(fr.top().second, x))); } } void pop(){ if (bk.empty()){ while (!fr.empty()){ T x = fr.top().first; fr.pop(); if (bk.empty()){ bk.push(make_pair(x, x)); } else { bk.push(make_pair(x, f(x, bk.top().second))); } } } bk.pop(); } T get(){ T ans1 = E; if (!fr.empty()){ ans1 = fr.top().second; } T ans2 = E; if (!bk.empty()){ ans2 = bk.top().second; } return f(ans2, ans1); } }; int main(){ int N, M, K; cin >> N >> M >> K; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector> B(N, vector(K, 0)); for (int i = 0; i < N; i++){ B[i][0]++; B[i][A[i]]++; } auto op = [&](vector A, vector B){ vector C = atcoder::convolution(A, B); for (int i = K; i < K * 2 - 1; i++){ C[i - K] += C[i]; C[i - K] %= MOD; } C.resize(K); return C; }; vector E(K, 0); E[0] = 1; sliding_window_aggregation> S(op, E); for (int i = 0; i < M; i++){ S.push(B[i]); } for (int i = 0; i <= N - M; i++){ cout << (S.get()[0] + MOD - 1) % MOD << endl; if (i < N - M){ S.pop(); S.push(B[i + M]); } } }