#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long mod = 998244353;
vector<int> G[3];
int n;
long long dp[N], k, f[N][2];
void init() {
  f[0][1] = 0;
  f[1][1] = k - 1;
  f[0][0] = 1;
  f[1][0] = k - 2;
  for (int i = 2; i < N - 10; ++i) {
    f[i][1] = (k - 1) * f[i - 1][0] % mod;
    f[i][0] = (f[i - 1][1] + (k - 2) * f[i - 1][0]) % mod;
  }
}
long long mod_pow(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long solve(int u) {
  int len = G[u].size();
  dp[0] = 1;
  int tot = 0;
  bool f1, f2;
  f1 = f2 = false;
  long long ans = 1;
  for (int i = 1; i < len; ++i)
    if (G[u][i] != -1) f2 = true;
  if (!f2) {
    ans = k * mod_pow(k - 1, len - 2) % mod;
    return ans;
  }
  for (int i = 1; i < len;) {
    if (G[u][i] == -1) {
      int j = i;
      while (j < len && G[u][j] == -1) {
        j++;
      }
      if (j != len) {
        if (f1) {
          if (G[u][j] == G[u][i - 1]) {
            ans = ans * f[j - i][1] % mod;
          } else {
            ans = ans * f[j - i][0] % mod;
          }
        } else {
          ans = ans * mod_pow(k - 1, j - i) % mod;
        }
      } else {
        ans = ans * mod_pow(k - 1, j - i) % mod;
      }
      i = j + 1;
    } else {
      if (G[u][i] == G[u][i - 1]) ans = 0;
      i++;
    }
    f1 = true;
  }
  return ans;
}
int main() {
  cin >> n >> k;
  init();
  int x;
  G[1].push_back(0);
  G[2].push_back(0);
  for (int i = (1); i < (n + 1); i++) {
    cin >> x;
    if (i & 1)
      G[1].push_back(x);
    else
      G[2].push_back(x);
  }
  long long ans = solve(1);
  ans = (ans * solve(2)) % mod;
  cout << ans << endl;
  return 0;
}
