#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
const double PI = acos(-1);
int n, k;
int a[N], b[N];
int cnta, cntb;
int pre[N];
int dp[N][2];
int Power(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return ans;
}
int getDp(int n, int a, int b) {
  if (n == 0) return 1;
  if (a == b) {
    dp[1][1] = 0;
    dp[1][0] = k - 1;
  } else {
    dp[1][1] = 1;
    dp[1][0] = k - 2;
  }
  for (int i = 1; i < n; i++) {
    dp[i + 1][0] =
        (1ll * dp[i][0] * (k - 2) % mod + 1ll * dp[i][1] * (k - 1) % mod) % mod;
    dp[i + 1][1] = dp[i][0];
  }
  return dp[n][0];
}
int solve(int *a, int n) {
  a[n + 1] = -1;
  for (int i = 1; i < n; i++)
    if (~a[i] && ~a[i + 1] && a[i] == a[i + 1]) return 0;
  if (k == 1 && n >= 2) return 0;
  if (k == 1 && n == 1) return 1;
  int pre = -1, ans = 1;
  for (int i = 1; i <= n; i++) {
    if (~a[i]) {
      if (pre == -1) {
        ans = 1ll * ans * Power(k - 1, i - 1) % mod;
      } else {
        ans = 1ll * ans * getDp(i - pre - 1, a[pre], a[i]) % mod;
      }
      pre = i;
    }
  }
  if (~pre)
    ans = 1ll * ans * Power(k - 1, n - pre) % mod;
  else
    ans = 1ll * ans * Power(k - 1, n - 1) % mod * k % mod;
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (i & 1)
      a[++cnta] = x;
    else
      b[++cntb] = x;
  }
  printf("%lld\n", 1ll * solve(a, cnta) * solve(b, cntb) % mod);
  return 0;
}
