#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, len;
  cin >> n >> k >> len;
  if (len == 1) {
    cout << 0;
    return 0;
  }
  int a[n], dp2[n][k];
  long long dp1[n][k];
  vector<long long> dp3(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < k; i++) {
    dp2[0][i] = (i + 1 == a[0] || -1 == a[0]);
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (a[i] == -1 || a[i] == j + 1) {
        dp2[i][j] = dp2[i - 1][j] + 1;
      } else {
        dp2[i][j] = 0;
      }
    }
  }
  for (int i = 0; i < k; i++) {
    dp1[0][i] = dp2[0][i];
    dp3[0] += dp1[0][i];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (dp2[i][j] >= len) {
        dp1[i][j] = (i + 1 == len ? dp3[i - 1] - 1 + 998244353
                                  : dp3[i - 1] - dp3[i - len] +
                                        dp1[i - len][j] + 998244353);
        dp1[i][j] %= 998244353;
      } else if (dp2[i][j]) {
        dp1[i][j] = dp3[i - 1];
      } else {
        dp1[i][j] = 0;
      }
      dp3[i] += dp1[i][j];
      dp3[i] %= 998244353;
    }
  }
  cout << dp3[n - 1];
}
