#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100, mod = 998244353;
inline int ksm(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
int f[maxn], g[maxn], n, k;
vector<int> v[2];
inline int check(const vector<int> &v) {
  for (int i = 0; i < (int)v.size(); i++)
    if (v[i] != -1) return 0;
  return 1;
}
inline int getans(const vector<int> &v) {
  if (check(v)) return 1ll * k * ksm(k - 1, v.size() - 1) % mod;
  int L = 0, R = v.size() - 1, cnt = 0;
  while (v[L] == -1) L++, cnt++;
  while (v[R] == -1) R--, cnt++;
  int cur = L;
  int ans = ksm(k - 1, cnt);
  for (;;) {
    int l = cur, r = cur;
    if (r >= R) break;
    while (v[r + 1] == -1) r++;
    r++;
    if (v[l] == v[r])
      ans = 1ll * ans * f[r - l - 1] % mod;
    else
      ans = 1ll * ans * g[r - l - 1] % mod;
    cur = r;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (i & 1)
      v[0].push_back(x);
    else
      v[1].push_back(x);
  }
  f[0] = 0;
  g[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      f[i] = (1ll * f[i >> 1] * f[i >> 1] % mod +
              1ll * (k - 1) * g[i >> 1] % mod * g[i >> 1] % mod) %
             mod;
      g[i] = (2ll * f[i >> 1] * g[i >> 1] % mod +
              1ll * (k - 2) * g[i >> 1] % mod * g[i >> 1] % mod) %
             mod;
    } else {
      f[i] = 1ll * (k - 1) * g[i - 1] % mod;
      g[i] = (f[i - 1] + 1ll * (k - 2) * g[i - 1] % mod) % mod;
    }
  }
  int ans = 1ll * getans(v[0]) * getans(v[1]) % mod;
  printf("%d\n", ans);
  return 0;
}
