#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<int> tab;
vector<vector<long long> > dp;
vector<long long> dpsum;
vector<vector<int> > prefSum;
vector<int> prefSum2;
inline int count(int v, int a, int b) {
  return prefSum[b + 1][v] - prefSum[a][v];
}
inline int count2(int a, int b) { return prefSum2[b + 1] - prefSum2[a]; }
const long long MOD = 998244353;
int32_t main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> m;
  if (m == 1) {
    cout << 0 << endl;
    return 0;
  }
  tab.resize(n);
  dpsum.resize(n);
  prefSum2.resize(n + 1);
  dp.resize(n, vector<long long>(k + 1));
  prefSum.resize(n + 1, vector<int>(k + 1));
  for (int i = 0; i < n; i++) {
    cin >> tab[i];
    for (int j = 1; j <= k; j++)
      prefSum[i + 1][j] = prefSum[i][j] + (tab[i] == j);
    prefSum2[i + 1] = prefSum2[i] + (tab[i] != -1);
  }
  if (tab[0] == -1) {
    for (int i = 1; i <= k; i++) dp[0][i] = 1;
    dpsum[0] = k;
  } else {
    dpsum[0] = dp[0][tab[0]] = 1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (tab[i] != -1 && tab[i] != j) {
        dp[i][j] = 0;
        continue;
      }
      dp[i][j] = dpsum[i - 1];
      if (i - m + 1 >= 0 && count(j, i - m + 1, i) == count2(i - m + 1, i)) {
        dp[i][j] =
            ((dp[i][j] - (i - m < 0 ? 1 : dpsum[i - m] - dp[i - m][j])) % MOD +
             MOD) %
            MOD;
      }
      dpsum[i] += dp[i][j];
    }
    dpsum[i] %= MOD;
  }
  cout << dpsum.back() << endl;
}
