#include <bits/stdc++.h>
#pragma GGC optimize("Ofast")
using namespace std;
template <typename T>
void dprintln(const T &t) {
  cout << t << endl;
}
template <typename T, typename... Args>
void dprintln(const T &t, const Args &...rest) {
  cout << t << ' ';
  dprintln(rest...);
}
template <typename T>
void println(const T &t) {
  cout << t << '\n';
}
template <typename T, typename... Args>
void println(const T &t, const Args &...rest) {
  cout << t << ' ';
  println(rest...);
}
template <typename T>
void print(const T &t) {
  cout << t << ' ';
}
template <typename T, typename... Args>
void print(const T &t, const Args &...rest) {
  cout << t << ' ';
  print(rest...);
}
template <class T>
void scan(T &t) {
  cin >> t;
}
template <class T, class... Args>
void scan(T &a, Args &...rest) {
  cin >> a;
  scan(rest...);
}
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
using pii = pair<int, int>;
using vb = vector<bool>;
using vpii = vector<pii>;
auto bet = [](const ll x, const ll y, const ll i) { return x <= i && i <= y; };
inline int h_bit(unsigned int x) { return 31 - __builtin_clz(x); }
inline int h_bitll(unsigned long long x) { return 63 - __builtin_clzll(x); }
template <typename T>
struct bit {
  vector<T> a;
  explicit bit(int n, int v = 0) {
    a.resize(n + 1);
    if (v != 0) {
      for (int i = 1; i <= n; ++i) a[i] = v;
    }
  }
  T sum(T x) {
    T res = 0;
    while (x) {
      res += a[x];
      x -= x & -x;
    }
    return res;
  }
  T sum(int l, int r) {
    if (l > r) return 0;
    return sum(r) - sum(l - 1);
  }
  void add(int x, T v) {
    while (x < a.size()) {
      a[x] += v;
      x += x & -x;
    }
  }
  void clear() { fill(a.begin(), a.end(), 0); }
};
vi get_prime(int n) {
  vi minp(n + 1), p;
  for (int i = 2; i <= n; i++) {
    if (!minp[i]) {
      minp[i] = i;
      p.push_back(i);
    }
    for (auto &x : p) {
      if (x <= minp[i] && x * i <= n)
        minp[x * i] = x;
      else
        break;
    }
  }
  return p;
}
const int mod = 998244353;
inline void add_mod(ll &x, const ll &y) {
  x += y;
  if (x >= mod) x -= mod;
}
void sub_mod(ll &x, const ll &y) {
  x -= y;
  if (x < 0) x += mod;
}
template <typename T>
using vv = vector<vector<T>>;
template <typename T1, typename T2 = T1>
using vp = vector<pair<T1, T2>>;
template <typename T, int n>
using va = vector<array<T, n>>;
struct UF {
  vi par;
  explicit UF(int n) {
    par.assign(n + 1, 0);
    for (int i = (1); i < (n + 1); ++i) par[i] = i;
  }
  int find(int x) { return x == par[x] ? x : par[x] = find(par[x]); }
  void unite(int x, int y) { par[find(x)] = find(y); }
};
vi get_popcnt(int n) {
  vi res(n + 1);
  for (int i = (0); i < (n); ++i) {
    if (i * 2 <= n) res[i * 2] = res[i];
    if ((i & 1) == 0) res[i + 1] = res[i] + 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k, len;
  scan(n, k, len);
  if (len == 1) return println(0), 0;
  vi a(n);
  for (auto &x : a) {
    scan(x);
    if (x == -1) ++x;
  }
  for (int i = 0; i < n;) {
    if (a[i] == 0)
      ++i;
    else {
      int j = i;
      while (i < n && a[i] == a[j]) ++i;
      if (i - j >= len) return println(0), 0;
    }
  }
  vv<ll> f(n, vl(k + 1));
  vl tot(n);
  vv<int> cnt(n, vi(k + 1));
  vi sum(k + 1);
  for (int i = (0); i < (n); ++i) {
    sum[a[i]]++;
    cnt[i] = sum;
  }
  vi type(n);
  fill(begin(type), end(type), -1);
  auto get_type = [&](int i) {
    if (i == len - 2) {
      for (int j = (1); j < (k + 1); ++j)
        if (cnt[i][j] + cnt[i][0] == len - 1) {
          type[i] = cnt[i][j] > 0 ? j : 0;
          break;
        }
    } else {
      int n0 = cnt[i][0] - cnt[i - len + 1][0];
      for (int j = (1); j < (k + 1); ++j)
        if (cnt[i][j] - cnt[i - len + 1][j] + n0 == len - 1) {
          type[i] = n0 == len - 1 ? 0 : j;
          break;
        }
    }
  };
  for (int i = (len - 2); i < (n); ++i) get_type(i);
  function<void(int, int, int)> transition;
  transition = [&](int i, int c1, int c2) {
    auto &t = f[i + 1][c2];
    if (c1 != 0) {
      auto s = f[i][c1];
      if (i >= len - 2 && c1 == c2 && (type[i] == 0 || type[i] == c1)) {
        if (i == len - 2) {
          add_mod(t, s ? s - 1 : mod - 1);
        } else {
          ll tmp = (s - (tot[i - len + 1] - f[i - len + 1][c1])) % mod;
          add_mod(t, tmp < 0 ? tmp + mod : tmp);
        }
      } else {
        add_mod(t, s);
      }
    } else {
      add_mod(t, tot[i] - f[i][c2] + (tot[i] < f[i][c2] ? mod : 0));
      transition(i, c2, c2);
    }
  };
  if (a[0] == 0)
    fill(begin(f[0]), end(f[0]), 1), tot[0] = k;
  else
    f[0][a[0]] = 1, tot[0] = 1;
  for (int i = (0); i < (n - 1); ++i) {
    if (a[i + 1] != 0)
      transition(i, a[i], a[i + 1]), tot[i + 1] = f[i + 1][a[i + 1]];
    else
      for (int j = (1); j < (k + 1); ++j)
        transition(i, a[i], j), add_mod(tot[i + 1], f[i + 1][j]);
  }
  println(tot[n - 1]);
  return 0;
}
