#include <bits/stdc++.h>
const long long mod = 998244353;
const int N = 2e5 + 5;
int n, k, a[N], b[N];
long long dp[N][2];
long long solve(int len, int L, int R) {
  long long ans = 1;
  if (!L && !R) {
    ans = k;
    for (int i = 1; i < len; i++) ans = ans * (k - 1) % mod;
  } else if (!L || !R) {
    for (int i = 1; i <= len; i++) ans = ans * (k - 1) % mod;
  } else {
    if (L == R)
      dp[1][0] = k - 1, dp[1][1] = 0;
    else
      dp[1][0] = k - 2, dp[1][1] = 1;
    for (int i = 1; i < len; i++) {
      (dp[i + 1][0] = (k - 2) * dp[i][0] + (k - 1) * dp[i][1]) %= mod;
      dp[i + 1][1] = dp[i][0];
    }
    ans = dp[len][0];
  }
  return ans;
}
long long work(int len) {
  long long ans = 1;
  int l = 1;
  for (int i = 1; i <= len; i++) {
    if (b[i] != -1) {
      if (l < i)
        ans = ans * solve(i - l, b[l - 1], b[i]) % mod;
      else if (b[i] == b[i - 1])
        ans = 0;
      l = i + 1;
    }
  }
  if (l <= len) ans = ans * solve(len - l + 1, b[l - 1], 0) % mod;
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    if (i & 1) b[++cnt] = a[i];
  }
  long long ans = work(cnt);
  cnt = 0;
  for (int i = 2; i <= n; i += 2) b[++cnt] = a[i];
  printf("%lld\n", ans * work(cnt) % mod);
  return 0;
}
