#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, P = 998244353;
int n, k, ans = 1, a[N], prv[2] = {-2, -1}, dp[N][4] = {{0, 1, 1, 1}};
int solve(int l, int r) {
  return a[l] && a[r] ? dp[r - l - 1 >> 1][a[l] != a[r]]
                      : dp[r - l - 1 >> 1][2 | !(a[l] || a[r])] % P;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i + 1][0] = (k - 1LL) * dp[i][1] % P;
    dp[i + 1][1] = (dp[i][0] + (k - 2LL) * dp[i][1]) % P;
    dp[i + 1][2] = (k - 1LL) * dp[i][2] % P;
    dp[i + 1][3] = 1LL * k * dp[i][2] % P;
  }
  for (int i = 0; i < n + 2; i++)
    if (~a[i]) {
      ans = 1LL * ans * solve(prv[i & 1], i) % P;
      prv[i & 1] = i;
    }
  cout << ans;
}
