#include <bits/stdc++.h>
using namespace std;
int n, m;
int ar[200003];
long long ans = 1;
long long dp1[200003][2];
long long dp2[200003][3];
vector<pair<int, int> > v[2];
void read() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
    if (ar[i] != -1 && ar[i] == ar[i - 2]) {
      puts("0");
      exit(0);
    }
  }
}
void dp() {
  dp1[1][1] = dp2[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    dp1[i][0] = (dp1[i - 1][0] * (m - 2) + dp1[i - 1][1] * (m - 1)) % 998244353;
    dp1[i][1] = dp1[i - 1][0];
    dp2[i][0] = (((dp2[i - 1][1] + dp2[i - 1][2]) % 998244353) * (m - 2) +
                 dp2[i - 1][0] * max(m - 3, 0)) %
                998244353;
    dp2[i][1] = (dp2[i - 1][0] + dp2[i - 1][2]) % 998244353;
    dp2[i][2] = (dp2[i - 1][0] + dp2[i - 1][1]) % 998244353;
  }
}
long long calcPow(long long x, int y) {
  if (!y) return 1;
  long long res = calcPow(x, y / 2);
  res = (res * res) % 998244353;
  if (y & 1) res = (res * x) % 998244353;
  return res;
}
void precalc() {
  for (int k = 0; k < 2; k++) {
    int l = k + 1, r = k + 1;
    while (l <= n) {
      r = l;
      if (ar[l] == -1) {
        while (r + 2 <= n && ar[r + 2] == -1) r += 2;
        v[k].push_back(pair<int, int>(0, (r - l) / 2 + 1));
      } else
        v[k].push_back(pair<int, int>(1, ar[l]));
      l = r + 2;
    }
  }
}
void solve() {
  for (int k = 0; k < 2; k++) {
    int sz = v[k].size();
    if (sz == 1 && v[k][0].first == 0)
      ans = ((ans * m) % 998244353 * calcPow(m - 1, v[k][0].second - 1)) %
            998244353;
    else if (sz > 1) {
      if (v[k][0].first == 0)
        ans = (ans * calcPow(m - 1, v[k][0].second)) % 998244353;
      if (v[k][sz - 1].first == 0)
        ans = (ans * calcPow(m - 1, v[k][sz - 1].second)) % 998244353;
      for (int i = 1; i < sz - 1; i++)
        if (v[k][i].first == 0) {
          if (v[k][i - 1].second == v[k][i + 1].second)
            ans = (ans * dp1[v[k][i].second + 2][1]) % 998244353;
          else
            ans = (ans * dp2[v[k][i].second + 2][2]) % 998244353;
        }
    }
  }
  printf("%I64d\n", ans);
}
int main() {
  read();
  dp();
  precalc();
  solve();
  return 0;
}
