#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(51);
const long long MOD = 998244353;
long long add(long long a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k, len;
  cin >> n >> k >> len;
  len--;
  if (len == 0) {
    cout << 0;
    return 0;
  }
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] != -1) a[i]--;
  }
  vector<vector<long long>> dp(n, vector<long long>(k));
  vector<long long> sum(k);
  long long sum_all = 0;
  vector<pair<long long, long long>> all;
  if (a[0] == -1) {
    for (long long i = 0; i < k; i++) {
      dp[0][i] = 1;
      sum[i]++;
      sum_all++;
      all.push_back({0, i});
    }
  } else {
    dp[0][a[0]] = 1;
    sum[a[0]]++;
    sum_all++;
    all.push_back({0, a[0]});
  }
  for (long long i = 1; i < n; i++) {
    if (a[i] == -1) {
      for (long long c = 0; c < k; c++) {
        dp[i][c] = sub(sum_all, sum[c]);
        all.push_back({i, c});
        sum[c] = add(sum[c], dp[i][c]);
      }
      for (long long c = 0; c < k; c++) sum_all = add(sum_all, dp[i][c]);
    } else {
      vector<pair<long long, long long>> nw;
      long long sumc = 0;
      for (auto to : all) {
        if (to.first < i - len) continue;
        if (to.second == a[i]) {
          nw.push_back(to);
        } else {
          sumc = add(sumc, dp[to.first][to.second]);
          sum_all = sub(sum_all, dp[to.first][to.second]);
          sum[to.second] = sub(sum[to.second], dp[to.first][to.second]);
          dp[to.first][to.second] = 0;
        }
      }
      all = nw;
      dp[i][a[i]] = sumc;
      sum_all = add(sum_all, dp[i][a[i]]);
      sum[a[i]] = add(sum[a[i]], dp[i][a[i]]);
      all.push_back({i, a[i]});
    }
    if (i >= len) {
      for (long long f = 0; f < k; f++) {
        sum_all = sub(sum_all, dp[i - len][f]);
        sum[f] = sub(sum[f], dp[i - len][f]);
        dp[i - len][f] = 0;
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < k; j++) {
      ans = add(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}
