#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, p = 998244353;
long long a[N], dp[N][105], tot[N], pref[N][105];
int nearestdiff[105], nearest[105];
int main() {
  int n, k, l;
  cin >> n >> k >> l;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (l == 1) {
    cout << "0\n";
    return 0;
  }
  for (int j = 1; j <= k; j++) nearestdiff[j] = nearest[j] = -1;
  long long xd = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) pref[i][j] = pref[i - 1][j];
    tot[i] = tot[i - 1];
    if (a[i] == -1) {
      for (int j = 1; j <= k; j++) {
        if (i >= l) {
          int lef = max(i - l + 1, nearestdiff[j]), rig = i - 1;
          dp[i][j] = ((tot[rig] - tot[lef - 1] + p) -
                      (pref[rig][j] - pref[lef - 1][j] + p) + p) %
                     p;
        } else
          dp[i][j] = xd;
        pref[i][j] = (pref[i][j] + dp[i][j]) % p;
        tot[i] = (tot[i] + dp[i][j]) % p;
      }
      xd = (xd * k) % p;
    } else {
      int j = a[i];
      if (i >= l) {
        int lef = max(i - l + 1, nearestdiff[j]), rig = i - 1;
        dp[i][j] = ((tot[rig] - tot[lef - 1] + p) -
                    (pref[rig][j] - pref[lef - 1][j] + p) + p) %
                   p;
      } else
        dp[i][j] = xd;
      pref[i][j] = (pref[i][j] + dp[i][j]) % p;
      tot[i] = (tot[i] + dp[i][j]) % p;
    }
    if (a[i] != -1) {
      nearestdiff[a[i]] = -1;
      for (int j = 1; j <= k; j++)
        if (j != a[i]) nearestdiff[a[i]] = max(nearestdiff[a[i]], nearest[j]);
      for (int j = 1; j <= k; j++)
        if (j != a[i]) nearestdiff[j] = i;
      nearest[a[i]] = i;
    }
  }
  cout << (tot[n] - tot[n - 1] + p) % p << "\n";
  return 0;
}
