#include <bits/stdc++.h>
using namespace std;
long long mult(long long a, long long b) { return (a * b) % 998244353ll; }
long long sum(long long a, long long b) { return (a + b) % 998244353ll; }
long long n, k, c, dp[200005], dpDiff[200005], ans = 1;
vector<long long> a[2];
long long getaa(int n) { return dp[n]; }
long long getab(int n) { return dpDiff[n]; }
long long geta(int n) { return sum(dp[n - 1], mult(dpDiff[n - 1], k - 1)); }
long long get(int n) {
  if (n == 1) return k;
  if (n == 2) return (k * (k - 1)) % 998244353ll;
  return mult(k, sum(dp[n - 2], mult(dpDiff[n - 2], k - 1)));
}
void dfs(int);
void dfsDiff(int);
void dfs(int n) {
  if (dp[n] != -1) return;
  if (n % 2 == 0) {
    dp[n] = mult((k - 1), dpDiff[n - 1]);
    return;
  }
  dfs(n / 2);
  dfsDiff(n / 2);
  dp[n] = mult(dp[n / 2], dp[n / 2]);
  dp[n] += mult(mult(dpDiff[n / 2], dpDiff[n / 2]), (k - 1));
  dp[n] %= 998244353ll;
}
void dfsDiff(int n) {
  if (dpDiff[n] != -1) return;
  if (n % 2 == 0) {
    dpDiff[n] = sum(mult((k - 2), dpDiff[n - 1]), dp[n - 1]);
    return;
  }
  dfs(n / 2);
  dfsDiff(n / 2);
  dpDiff[n] = mult(2, mult(dpDiff[n / 2], dp[n / 2]));
  dpDiff[n] += mult(k - 2, mult(dpDiff[n / 2], dpDiff[n / 2]));
  dpDiff[n] %= 998244353ll;
}
void solve(vector<long long>& a) {
  int cnt = 0;
  int l = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != -1) {
      cnt = 0;
      l = i + 1;
      continue;
    }
    cnt++;
    if (i == a.size() - 1 || a[i] != a[i + 1]) {
      if (i == a.size() - 1) {
        if (l == 0) {
          ans *= get(cnt);
          ans %= 998244353ll;
        } else {
          ans *= geta(cnt);
          ans %= 998244353ll;
        }
      } else {
        if (l == 0) {
          ans *= geta(cnt);
          ans %= 998244353ll;
        } else {
          if (a[l - 1] == a[i + 1])
            ans *= getaa(cnt);
          else
            ans *= getab(cnt);
          ans %= 998244353ll;
        }
      }
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i <= n; i++) dp[i] = dpDiff[i] = -1;
  dp[0] = 0;
  dpDiff[0] = 1;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &c);
    a[i % 2].push_back(c);
  }
  for (int i = 0; i < a[0].size() - 1; i++)
    if (a[0][i] == a[0][i + 1] && a[0][i] != -1) {
      cout << 0 << endl;
      return 0;
    }
  for (int i = 0; i < a[1].size() - 1; i++)
    if (a[1][i] == a[1][i + 1] && a[1][i] != -1) {
      cout << 0 << endl;
      return 0;
    }
  for (int i = 1; i <= n; i++) {
    dfs(i);
    dfsDiff(i);
  }
  solve(a[0]);
  solve(a[1]);
  cout << ans << endl;
  return 0;
}
