#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  x = x % 998244353;
  while (y > 0) {
    if (y & 1) res = (res * x) % 998244353;
    y = y >> 1;
    x = (x * x) % 998244353;
  }
  return res;
}
vector<vector<long long> > newdp(long long A, long long B) {
  vector<vector<long long> > dp;
  dp.resize(A + 1);
  for (int i = 0; i < A + 1; i++) {
    dp[i].resize(B + 1);
    for (int j = 0; j < B + 1; j++) dp[i][j] = -1;
  }
  return dp;
}
vector<long long> all_prime;
void prime() {
  bool hash[1000000];
  memset(hash, false, sizeof hash);
  for (int p = 2; p * p < 1000000; p++)
    if (hash[p] == true)
      for (int i = p * 2; i < 1000000; i += p) hash[i] = false;
  for (int i = 2; i < 1000000; i++)
    if (hash[i]) all_prime.push_back(i);
}
struct Query {
  long long l, r, id;
};
bool cmp(Query A, Query B) {
  if (A.l / 320 != B.l / 320) return A.l < B.l;
  return A.l / 320 % 2 ? A.r > B.r : A.r < B.r;
}
long long k;
long long mult(long long a, long long b) {
  return (a * b + 998244353) % 998244353;
}
long long gotans(vector<long long> v) {
  long long n = v.size();
  long long dp[n][2];
  if (n == 1) return 1;
  if (v.back() == -1) {
    long long ans = 1;
    ans = (v[0] == -1) ? k : 1;
    for (long long i = 1; i < v.size(); i++) ans = mult(ans, k - 1);
    return ans;
  } else {
    if (v[0] == -1) {
      dp[0][0] = k - 1;
      dp[0][1] = 1;
    } else {
      if (v[0] == v.back()) {
        dp[0][0] = 0;
        dp[0][1] = 1;
      } else {
        dp[0][0] = 1;
        dp[0][1] = 0;
      }
    }
    for (long long i = 1; i < v.size(); i++) {
      dp[i][1] = dp[i - 1][0] % 998244353;
      dp[i][0] = (mult(dp[i - 1][0], (k - 2)) + mult(dp[i - 1][1], (k - 1)) +
                  998244353) %
                 998244353;
    }
    return dp[v.size() - 1][1] % 998244353;
  }
}
long long distribute(vector<long long> v) {
  int l = 0, r = 1;
  long long ans = 1;
  while (r < v.size()) {
    while (r < v.size() && v[r] == -1) r++;
    if (r == v.size()) r--;
    vector<long long> newv;
    for (long long i = l; i <= r; i++) newv.push_back(v[i]);
    ans = mult(ans, gotans(newv));
    l = r++;
  }
  return ans;
}
int main(int argc, char const *argv[]) {
  long long n;
  cin >> n >> k;
  vector<long long> bandri[2];
  long long ar[n];
  for (long long i = 0, ele; i < n; i++)
    cin >> ele, bandri[i & 1].push_back(ele), ar[i] = ele;
  long long ans = mult(distribute(bandri[0]), distribute(bandri[1]));
  if (n <= 2) {
    ans = 1;
    for (int i = 0; i < n; i++)
      if (ar[i] == -1) ans = mult(ans, k);
  }
  cout << ans;
  return 0;
}
