#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, k, l;
  cin >> n >> k >> l;
  if (l == 1) {
    cout << "0\n";
    return 0;
  }
  int ts = 0, tts;
  vector<int> s(k);
  vector<deque<int>> t(k);
  int x;
  cin >> x;
  x -= x > 0;
  if (x != -1)
    t[x].push_back(1), s[x] = 1, ++ts;
  else
    for (int i = 0; i < k; ++i) t[i].push_back(1), s[i] = 1, ++ts;
  auto put = [&]() {
    int a = ts - s[x];
    if (a < 0) a += mod;
    t[x].push_front(a);
    s[x] += a;
    tts += a;
    if (s[x] >= mod) s[x] -= mod;
    if (tts >= mod) tts -= mod;
    if (t[x].size() == l) {
      s[x] -= t[x].back();
      tts -= t[x].back();
      if (s[x] < 0) s[x] += mod;
      if (tts < 0) tts += mod;
      t[x].pop_back();
    }
  };
  for (int i = 1; i < n; ++i) {
    cin >> x;
    x -= x > 0;
    if (x != -1) {
      tts = ts;
      put();
      ts = tts;
      for (int j = 0; j < k; ++j)
        if (j != x) {
          t[j].clear();
          ts -= s[j];
          if (ts < 0) ts += mod;
          s[j] = 0;
        }
    } else {
      tts = ts;
      for (x = 0; x < k; ++x) put();
      ts = tts;
    }
  }
  cout << ts << "\n";
  return 0;
}
