#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long n, k, a[200005], cntSame[200005], cntDiff[200005], power[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cntSame[0] = 0;
  cntDiff[0] = 1;
  power[0] = 1;
  for (int i = 1; i <= n; i++) {
    cntSame[i] = ((k - 1) * cntDiff[i - 1]) % MOD;
    cntDiff[i] = (cntSame[i - 1] + ((k - 2) * cntDiff[i - 1]) % MOD) % MOD;
    power[i] = (power[i - 1] * (k - 1)) % MOD;
  }
  long long even = 1, last = -1, cnt = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] == -1) {
      cnt++;
    } else {
      if (last == -1)
        even = (even * power[cnt]) % MOD;
      else
        even = (even * (a[last] == a[i] ? cntSame[cnt] : cntDiff[cnt])) % MOD;
      cnt = 0;
      last = i;
    }
  }
  if (last == -1)
    even = (even * (power[cnt - 1] * k) % MOD) % MOD;
  else
    even = (even * power[cnt]) % MOD;
  long long odd = 1;
  last = -1;
  cnt = 0;
  for (int i = 1; i < n; i += 2) {
    if (a[i] == -1) {
      cnt++;
    } else {
      if (last == -1)
        odd = (odd * power[cnt]) % MOD;
      else
        odd = (odd * (a[last] == a[i] ? cntSame[cnt] : cntDiff[cnt])) % MOD;
      cnt = 0;
      last = i;
    }
  }
  if (last == -1)
    odd = (odd * (power[cnt - 1] * k) % MOD) % MOD;
  else
    odd = (odd * power[cnt]) % MOD;
  cout << (even * odd) % MOD << '\n';
  return 0;
}
