#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m, dp[100010][102], a[100010], k, len, s[100010];
int c[100010][102], sum[100010];
int main() {
  n = read(), m = read(), len = read();
  if (len == 1) return !printf("0\n");
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
  }
  s[0] = sum[0] = 1;
  int t1 = 0, t2 = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (~a[i] && j ^ a[i]) continue;
      int k = max(-1, i - len);
      if (j == a[t2])
        k = max(k, t1 - 1);
      else
        k = max(k, t2 - 1);
      dp[i][j] = (sum[i - 1] - (~k ? sum[k] : 0) -
                  (c[i - 1][j] - (~k ? c[k][j] : 0))) %
                 mod;
      dp[i][j] = (dp[i][j] + mod) % mod;
      s[i] = (s[i] + dp[i][j]) % mod;
    }
    for (int j = 1; j <= m; ++j) {
      c[i][j] = (c[i - 1][j] + dp[i][j]) % mod;
    }
    sum[i] = (sum[i - 1] + s[i]) % mod;
    if (~a[i]) {
      if (a[i] == a[t2])
        t2 = i;
      else
        t1 = t2, t2 = i;
    }
  }
  printf("%d\n", s[n]);
  return 0;
}
