#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 998244353;
struct mint {
  ll x;
  mint(ll _x = 0) {
    if ((_x %= mod) < 0) _x += mod;
    x = _x;
  }
  bool operator==(const mint a) { return x == a.x; }
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  ll val() { return x; }
};
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> odd, even;
  for (int i = 0; i < (int)n; i++) {
    int a;
    cin >> a;
    if (i % 2)
      odd.push_back(a);
    else
      even.push_back(a);
  }
  vector<vector<mint>> b(n + 1, vector<mint>(2));
  b[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (int)2; j++) b[i][j] = mint(k - 1).pow(i) - b[i - 1][j];
  auto calc = [&](vector<int>& v) -> mint {
    int l = v.size();
    for (int i = 1; i < l; i++)
      if (v[i] == v[i - 1] and v[i] != -1) return 0;
    mint res = 1;
    int pos = 0;
    while (pos < l) {
      if (v[pos] == -1) {
        vector<int> nei;
        int len = 0;
        if (pos - 1 >= 0) nei.push_back(v[pos - 1]);
        while (v[pos] == -1 and pos < l) {
          len++;
          pos++;
        }
        if (pos < l) nei.push_back(v[pos]);
        if (nei.size() == 0)
          res *= mint(k) * mint(k - 1).pow(len - 1);
        else if (nei.size() == 1)
          res *= mint(k - 1).pow(len);
        else
          res *= (nei[0] == nei[1] ? b[len][1] : b[len][0]);
      } else {
        pos++;
      }
    }
    return res;
  };
  mint ans = calc(odd) * calc(even);
  cout << ans.val() << endl;
  return 0;
}
