#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
const long long MOD = 998244353;
int f[maxn][105], sum[maxn][105];
int pos[105], a[maxn], cnt[105], pre[105], suf[105];
int main() {
  int n, k, len;
  scanf("%d%d%d", &n, &k, &len);
  if (len == 1) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  if (a[1] >= 1)
    f[1][a[1]] = 1, pos[a[1]] = 1;
  else
    fill(f[1] + 1, f[1] + k + 1, 1), fill(sum[1] + 1, sum[1] + k + 1, k - 1);
  for (int i = 1; i <= k; ++i) pre[i] = max(pre[i - 1], pos[i]);
  for (int i = k; i >= 1; --i) suf[i] = max(suf[i + 1], pos[i]);
  f[0][0] = 1;
  for (int i = 2; i <= n; ++i) {
    int x = a[i];
    if (x >= 1) {
      int L = max(pre[x - 1], suf[x + 1]);
      if (i - L < len) f[i][x] = f[L][a[L]];
      f[i][x] = (f[i][x] + sum[i - 1][x] - sum[max(L, i - len)][x]) % MOD;
      for (int j = 1; j <= k; ++j) sum[i][j] = sum[i - 1][j];
      pos[x] = i;
      for (int j = 1; j <= k; ++j) pre[j] = max(pre[j - 1], pos[j]);
      for (int j = k; j >= 1; --j) suf[j] = max(suf[j + 1], pos[j]);
    } else {
      int S = 0;
      for (int x = 1; x <= k; ++x) {
        int L = max(pre[x - 1], suf[x + 1]);
        if (i - L < len) f[i][x] = f[L][a[L]];
        f[i][x] = (f[i][x] + sum[i - 1][x] - sum[max(L, i - len)][x]) % MOD;
        S = (S + f[i][x]) % MOD;
      }
      for (int j = 1; j <= k; ++j)
        sum[i][j] = (sum[i - 1][j] + S - f[i][j]) % MOD;
    }
  }
  int ans = 0;
  for (int i = 1; i <= k; ++i) ans = (ans + f[n][i]) % MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}
