#include <bits/stdc++.h>
int main() {
  int32_t n, k, len;
  std::cin >> n >> k >> len;
  if (len == 1) {
    std::cout << 0;
    return 0;
  }
  int32_t* arr = new int32_t[n];
  for (int32_t i = 0; i < n; i++) {
    std::cin >> arr[i];
    arr[i] -= arr[i] == -1 ? 0 : 1;
  }
  int32_t** dp = new int32_t*[n];
  dp[0] = new int32_t[k];
  for (int32_t i = 0; i < k; i++)
    dp[0][i] = arr[0] == -1 ? 1 : (arr[0] == i ? 1 : 0);
  int32_t* total_sum_pref = new int32_t[n + 1];
  total_sum_pref[0] = 0;
  total_sum_pref[1] = arr[0] == -1 ? k : 1;
  int32_t** color_sum_pref = new int32_t*[k];
  for (int32_t i = 0; i < k; i++) {
    color_sum_pref[i] = new int32_t[n + 1];
    color_sum_pref[i][0] = 0;
    color_sum_pref[i][1] = dp[0][i];
  }
  int32_t last_definte = arr[0] == -1 ? -1 : 0;
  int32_t* last_occ = new int32_t[k];
  for (int32_t i = 0; i < k; i++) last_occ[i] = -1;
  for (int32_t i = 1; i < n; i++) {
    dp[i] = new int32_t[k];
    total_sum_pref[i + 1] = total_sum_pref[i];
    for (int32_t j = 0; j < k; j++) {
      color_sum_pref[j][i + 1] = color_sum_pref[j][i];
      if (arr[i] != j && arr[i] != -1)
        dp[i][j] = 0;
      else {
        if (last_definte == -1 || i - last_definte >= len) {
          dp[i][j] = (total_sum_pref[i] -
                      total_sum_pref[std::max(i - len + 1, 0)] + 998244353) %
                     998244353;
          dp[i][j] -=
              (color_sum_pref[j][i] -
               color_sum_pref[j][std::max(i - len + 1, 0)] + 998244353) %
              998244353;
          dp[i][j] = (dp[i][j] + 998244353) % 998244353;
          if (i < len - 1) dp[i][j] = (dp[i][j] + 1) % 998244353;
        } else {
          if (j != arr[last_definte]) {
            dp[i][j] =
                (total_sum_pref[i] - total_sum_pref[last_definte] + 998244353) %
                998244353;
            dp[i][j] -= (color_sum_pref[j][i] -
                         color_sum_pref[j][last_definte] + 998244353) %
                        998244353;
            dp[i][j] = (dp[i][j] + 998244353) % 998244353;
          } else {
            int32_t last = i - len;
            bool exist_other = false;
            for (int32_t p = 0; p < k; p++)
              if (p != arr[last_definte]) {
                last = std::max(last, last_occ[p] - 1);
                if (last_occ[p] != -1) exist_other = true;
              }
            dp[i][j] = (total_sum_pref[i] -
                        total_sum_pref[std::max(last + 1, 0)] + 998244353) %
                       998244353;
            dp[i][j] -= (color_sum_pref[j][i] -
                         color_sum_pref[j][std::max(last + 1, 0)] + 998244353) %
                        998244353;
            dp[i][j] = (dp[i][j] + 998244353) % 998244353;
            if (i < len - 1 && !exist_other)
              dp[i][j] = (dp[i][j] + 1) % 998244353;
          }
        }
      }
      total_sum_pref[i + 1] += dp[i][j];
      total_sum_pref[i + 1] %= 998244353;
      color_sum_pref[j][i + 1] += dp[i][j];
      color_sum_pref[j][i + 1] %= 998244353;
    }
    if (arr[i] != -1) {
      last_definte = i;
      last_occ[arr[i]] = i;
    }
  }
  int32_t answer = 0;
  for (int32_t i = 0; i < k; i++) {
    answer += dp[n - 1][i];
    answer %= 998244353;
  }
  std::cout << answer;
  return 0;
}
