#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, len;
  cin >> n >> k >> len;
  --len;
  if (!len) {
    cout << 0;
    return 0;
  }
  vector<vector<int> > pref(n + 1, vector<int>(k + 2));
  auto getSum = [&pref](int L, int R, int lastValue) {
    if (L > R) {
      return 0;
    }
    int sum = pref[R][lastValue];
    if (L - 1 >= 0) {
      sum -= pref[L - 1][lastValue];
      if (sum < 0) {
        sum += MOD;
      }
    }
    return sum;
  };
  vector<vector<int> > dp(n + 1, vector<int>(k + 1));
  vector<int> lastNone(k + 1, 0);
  dp[0][0] = dp[0][k + 1] = 1;
  pref[0][0] = pref[0][k + 1] = 1;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    if (a != -1) {
      int L = max(lastNone[a], i - len);
      int R = i - 1;
      dp[i][a] = getSum(L, R, k + 1) - getSum(L, R, a);
      if (dp[i][a] < 0) {
        dp[i][a] += MOD;
      }
      for (int j = 1; j <= k; ++j) {
        if (j != a) {
          lastNone[j] = i;
        }
      }
    } else {
      for (int j = 1; j <= k; ++j) {
        int L = max(lastNone[j], i - len);
        int R = i - 1;
        dp[i][j] = getSum(L, R, k + 1) - getSum(L, R, j);
        if (dp[i][j] < 0) {
          dp[i][j] += MOD;
        }
      }
    }
    for (int j = 0; j <= k; ++j) {
      pref[i][j] = dp[i][j] + pref[i - 1][j];
      if (pref[i][j] >= MOD) {
        pref[i][j] -= MOD;
      }
      pref[i][k + 1] += pref[i][j];
      if (pref[i][k + 1] >= MOD) {
        pref[i][k + 1] -= MOD;
      }
    }
  }
  int answer = 0;
  for (int i = 1; i <= k; ++i) {
    answer += dp[n][i];
    if (answer >= MOD) {
      answer -= MOD;
    }
  }
  cout << answer;
  return 0;
}
