#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k, len, i, j, MOD = 998244353, ans, l, r, id, x;
  cin >> n >> k >> len;
  vector<long long> a(n + 1);
  for (i = 1; i <= n; i++) cin >> a[i];
  set<pair<long long, long long>> ss;
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  vector<long long> s(n + 1, 0);
  dp[0][0] = 1;
  s[0] = 1;
  for (i = 1; i <= n; i++) {
    if (a[i] == -1)
      l = 1, r = k;
    else
      l = a[i], r = a[i];
    if (a[i] != -1) ss.insert({a[i], i});
    if (i - len >= 1) ss.erase({a[i - len], i - len});
    if (ss.empty())
      id = -1;
    else if (ss.begin()->first == ss.rbegin()->first)
      id = ss.begin()->first;
    else
      id = -2;
    for (j = l; j <= r; j++) {
      dp[i][j] = s[i - 1];
      if (i - len < 0) continue;
      if ((id == -1) || (id == j)) {
        x = s[i - len] - dp[i - len][j];
        dp[i][j] = (dp[i][j] + MOD - x) % MOD;
      }
    }
    s[i] = 0;
    for (j = l; j <= r; j++) s[i] += dp[i][j];
    s[i] %= MOD;
  }
  ans = s[n] % MOD;
  cout << ans << "\n";
  return 0;
}
