#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int mod(long long x) {
  x %= 998244353;
  if (x < 0) x += 998244353;
  return x;
}
int Fe(int x, int y) {
  if (!y) return 1LL;
  int h = Fe(x, y / 2);
  h = mod(h * 1LL * h);
  if (y & 1) h = mod(h * 1LL * x);
  return h;
}
int dp[200009], k;
int f(int x, int y, int n) {
  n += 2;
  dp[0] = 1;
  for (int i = 2; i <= n; i++)
    dp[i] =
        mod(mod(dp[i - 2] * 1LL * (k - 1)) + mod(dp[i - 1] * 1LL * (k - 2)));
  if (x == y)
    return dp[n - 1];
  else
    return mod(dp[n] * 1LL * Fe(k - 1, 998244353 - 2));
}
int solve(vector<int> v) {
  int last = -1, cnt = 0, res = 1;
  for (int i = 0; i < v.size(); i++) {
    if (~v[i]) {
      if (~last)
        res = mod(res * 1LL * f(last, v[i], cnt));
      else
        res = mod(res * 1LL * Fe(k - 1, cnt));
      last = v[i];
      cnt = 0;
    } else
      cnt++;
  }
  if (~last) return mod(res * 1LL * Fe(k - 1, cnt));
  return mod(Fe(k - 1, v.size() - 1) * 1LL * k);
}
int arr[200009];
int main() {
  int n;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", arr + i);
  for (int i = 1; i + 2 <= n; i++)
    if (~arr[i] and ~arr[i + 2] and arr[i] == arr[i + 2]) return puts("0") * 0;
  vector<int> a, b;
  for (int i = 1; i <= n; i += 2) a.push_back(arr[i]);
  for (int i = 2; i <= n; i += 2) b.push_back(arr[i]);
  printf("%d\n", mod(solve(a) * 1LL * solve(b)));
  return 0;
}
