#include <bits/stdc++.h>
using namespace std;
long long read(int x = 0) {
  int c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
long long fastpow(long long a, long long b) {
  long long t = a, ans = 1;
  for (; b; b >>= 1, t = t * t % 998244353ll)
    if (b & 1) ans = ans * t % 998244353ll;
  return ans;
}
long long ans = 1, N, buf[300010], a[300010], K, f[300010][2], x[300010],
          y[300010], l1, l2;
long long solve(long long *a, long long len) {
  if (len == 0) return 1ll;
  long long i, ans = 1, l, r, j, cnt = 0;
  for (l = 1; l <= len and a[l] == -1; l++)
    ;
  if (l > len) {
    return K * fastpow(K - 1, len - 1) % 998244353ll;
  }
  for (r = len; a[r] == -1; r--)
    ;
  ans = ans * fastpow(K - 1, l - 1) % 998244353ll;
  ans = ans * fastpow(K - 1, len - r) % 998244353ll;
  for (i = l + 1; i < r; i = j + 1) {
    cnt = 0;
    for (j = i; a[j] == -1; j++) cnt++;
    ans = ans * f[cnt][a[i - 1] != a[j]] % 998244353ll;
  }
  return ans;
}
int main() {
  long long i, j;
  N = read(), K = read();
  for (i = 1; i <= N; i++) a[i] = read();
  for (i = 1; i <= N; i += 2) x[++l1] = a[i];
  for (i = 2; i <= N; i += 2) y[++l2] = a[i];
  f[0][0] = 0;
  f[0][1] = 1;
  for (i = 1; i <= N; i++) {
    f[i][0] = (K - 1) * f[i - 1][1];
    f[i][1] = f[i - 1][0] + (K - 2) * f[i - 1][1];
    f[i][0] %= 998244353ll;
    f[i][1] %= 998244353ll;
  }
  cout << solve(x, l1) * solve(y, l2) % 998244353ll;
  return 0;
}
