#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int norm(int a) {
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
  return a;
}
int mul(int a, int b) { return int(a * 1ll * b % MOD); }
int n, k;
vector<int> a;
inline bool read() {
  if (!(cin >> n >> k)) return false;
  a.resize(n);
  for (int i = int(0); i < int(n); i++) cin >> a[i];
  return true;
}
pair<int, int> calc(int len) {
  if (len == 0) return {0, 1};
  if (len & 1) {
    auto res = calc(len >> 1);
    return {norm(mul(res.first, res.first) +
                 mul(k - 1, mul(res.second, res.second))),
            norm(mul(2, mul(res.first, res.second)) +
                 mul(k - 2, mul(res.second, res.second)))};
  }
  auto res = calc(len - 1);
  return {mul(k - 1, res.second), norm(res.first + mul(k - 2, res.second))};
}
vector<int> curArray;
int calcSeg(int l, int r) {
  if (r >= int((curArray).size())) {
    int len = r - l - 1, cf = 1;
    if (l < 0) len--, cf = k;
    if (len == 0) return cf;
    auto res = calc(len - 1);
    return mul(cf, norm(res.first + mul(k - 1, res.second)));
  }
  if (l < 0) {
    if (r - l == 1) return 1;
    auto res = calc(r - l - 2);
    return norm(res.first + mul(k - 1, res.second));
  }
  auto res = calc(r - l - 1);
  return curArray[l] == curArray[r] ? res.first : res.second;
}
inline void solve() {
  int ans = 1;
  for (int k = int(0); k < int(2); k++) {
    curArray.clear();
    for (int i = 0; 2 * i + k < n; i++) curArray.push_back(a[2 * i + k]);
    int lst = -1;
    for (int i = int(0); i < int(int((curArray).size())); i++) {
      if (curArray[i] == -1) continue;
      ans = mul(ans, calcSeg(lst, i));
      lst = i;
    }
    ans = mul(ans, calcSeg(lst, int((curArray).size())));
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  if (read()) {
    solve();
  }
  return 0;
}
