#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
  os << "(" << v.first << " " << v.second << ")";
  return os;
}
template <typename T, typename U = typename T::value_type,
          typename = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, const T& v) {
  os << '[';
  for (const auto& it : v) os << it << " ";
  if (!v.empty()) os << "\b";
  os << "]";
  return os;
}
const int kMaxN = 2e5;
const int kMod = 998244353;
int64_t mod_pow(int base, int exp) {
  if (exp == 0) return 1;
  int64_t res = mod_pow(base, exp / 2);
  res = (res * res) % kMod;
  if (exp % 2) res = (res * base) % kMod;
  return res;
}
int K;
int64_t f[kMaxN], g[kMaxN];
int64_t solve(const vector<int>& vec) {
  if (vec.empty()) return 1;
  vector<int> pos;
  for (size_t i = 0; i < vec.size(); i++)
    if (vec[i] != -1) pos.push_back(i);
  if (pos.empty()) return (K * mod_pow(K - 1, vec.size() - 1)) % kMod;
  int64_t res = 1;
  res = (res * mod_pow(K - 1, pos[0])) % kMod;
  res = (res * mod_pow(K - 1, vec.size() - pos.back() - 1)) % kMod;
  for (int i = 1; i < pos.size(); i++) {
    int ii = pos[i - 1], jj = pos[i];
    int len = jj - ii - 1, cur;
    if (vec[ii] == vec[jj])
      cur = f[len];
    else
      cur = g[len];
    res = (res * cur) % kMod;
  }
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  int N, x;
  cin >> N >> K;
  vector<int> str[2];
  for (int i = 0; i < (N); i++) {
    cin >> x;
    str[i % 2].push_back(x);
  }
  f[0] = 0;
  g[0] = 1;
  for (int i = 1; i <= N / 2; i++) {
    f[i] = ((K - 1) * g[i - 1]) % kMod;
    g[i] = (f[i - 1] + (K - 2) * g[i - 1]) % kMod;
  }
  cout << (solve(str[0]) * solve(str[1])) % kMod << endl;
  return 0;
}
