#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
const int inf = 1000000000;
const int MAXL = 500;
long long int poW(long long int a, long long int b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    long long int t = poW(a, b / 2);
    return (t * t) % mod;
  } else {
    long long int t = poW(a, (b - 1) / 2);
    t = (t * t) % mod;
    return (t * a) % mod;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (i % 2 == 0)
      a.push_back(x);
    else
      b.push_back(x);
  }
  long long int ans = 0;
  long long int res = 0;
  vector<long long int> f(n + 1);
  f[1] = 0;
  long long int t = k - 1;
  for (int i = 2; i <= n; i++) {
    t = (t * (k - 1)) % mod;
    f[i] = (t - f[i - 1] + mod) % mod;
  }
  int m = a.size();
  int pre = -1;
  int cnt = 0;
  res = 1;
  for (int i = 0; i < m; i++) {
    if (a[i] == -1)
      cnt++;
    else {
      if (cnt == 0) {
        res = pre == a[i] ? 0 : res;
      } else {
        if (pre != -1) {
          long long int x = (pre == a[i] || pre == -1) ? k - 1 : k - 2;
          if (cnt % 2 == 0) x = -x;
          x = (x + mod + f[cnt]) % mod;
          res = (res * x) % mod;
        } else {
          long long int x = poW(k - 1, cnt);
          res = (res * x) % mod;
        }
        cnt = 0;
      }
      pre = a[i];
    }
  }
  if (cnt != 0) {
    long long int y = pre == -1 ? k : k - 1;
    y = (y * poW(k - 1, cnt - 1)) % mod;
    res = (res * y) % mod;
  }
  m = b.size();
  pre = -1;
  cnt = 0;
  ans = res;
  res = 1;
  for (int i = 0; i < m; i++) {
    if (b[i] == -1)
      cnt++;
    else {
      if (cnt == 0) {
        res = pre == b[i] ? 0 : res;
      } else {
        if (pre != -1) {
          long long int x = (pre == b[i] || pre == -1) ? k - 1 : k - 2;
          if (cnt % 2 == 0) x = -x;
          x = (x + mod + f[cnt]) % mod;
          res = (res * x) % mod;
        } else {
          long long int x = poW(k - 1, cnt);
          res = (res * x) % mod;
        }
        cnt = 0;
      }
      pre = b[i];
    }
  }
  if (cnt != 0) {
    long long int z = pre == -1 ? k : k - 1;
    z = (z * poW(k - 1, cnt - 1)) % mod;
    res = (res * z) % mod;
  }
  ans = (ans * res) % mod;
  cout << ans;
  return 0;
}
