#include <bits/stdc++.h>
int n, k, lst, cnt, p, a[200005], opt = 0;
long long f[200005], g[200005], ans = 1;
long long fp(long long x, int y) {
  return (y & 1 ? x : 1ll) * (y / 2 ? fp(x * x % 998244353, y / 2) : 1ll) %
         998244353;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  f[0] = 1;
  f[1] = k - 2;
  for (int i = 2; i <= n; i++)
    f[i] = (fp(k - 1, i) - f[i - 1] + 998244353) % 998244353;
  g[0] = 1;
  g[1] = k - 1;
  for (int i = 2; i <= n; i++)
    g[i] = (fp(k - 1, i) - g[i - 1] + 998244353) % 998244353;
  lst = -1, cnt = 0, p = 0;
  for (int i = 1; i <= n; i = i + 2) {
    ++p;
    if (a[i] == -1) ++cnt;
    if (a[i] != -1) {
      if (lst == -1)
        ans = ans * fp(k - 1, cnt) % 998244353;
      else if (lst == a[i])
        cnt ? (ans = ans * g[cnt] % 998244353, opt = 1) : ans = 0;
      else if (lst != a[i])
        ans = ans * f[cnt] % 998244353;
      lst = a[i];
      cnt = 0;
    }
  }
  if (cnt) {
    if (cnt == p)
      ans = ans * k % 998244353 * fp(k - 1, p - 1) % 998244353;
    else
      ans = ans * fp(k - 1, cnt) % 998244353;
  }
  lst = -1, cnt = 0, p = 0;
  for (int i = 2; i <= n; i = i + 2) {
    ++p;
    if (a[i] == -1) ++cnt;
    if (a[i] != -1) {
      if (lst == -1)
        ans = ans * fp(k - 1, cnt) % 998244353;
      else if (lst == a[i])
        cnt ? (ans = ans * g[cnt] % 998244353, opt = 1) : ans = 0;
      else if (lst != a[i])
        ans = (ans * f[cnt]) % 998244353;
      lst = a[i];
      cnt = 0;
    }
  }
  if (cnt) {
    if (cnt == p)
      ans = ans * k % 998244353 * fp(k - 1, p - 1) % 998244353;
    else
      ans = ans * fp(k - 1, cnt) % 998244353;
  }
  if (opt && k == 2) ans = 0;
  printf("%lld\n", ans);
  return 0;
}
