#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100, MOD = 998244353;
int sum(int a, int b) {
  a += b;
  if (a < 0)
    a += MOD;
  else if (a >= MOD)
    a -= MOD;
  return a;
}
void _sum(int &a, int b) { a = sum(a, b); }
int mul(int a, int b) { return 1LL * a * b % MOD; }
void _mul(int &a, int b) { a = mul(a, b); }
int n, k, a, same[N], dif[N];
vector<int> A, B;
void calc_dp() {
  same[0] = 0;
  dif[0] = 1;
  for (int i = 1; i < N; i++) {
    same[i] = mul(k - 1, dif[i - 1]);
    dif[i] = sum(same[i - 1], mul(k - 2, dif[i - 1]));
  }
}
int solve(vector<int> vec) {
  int res = 1;
  if (vec.empty()) return res;
  if (*max_element(vec.begin(), vec.end()) == -1) {
    res = k;
    vec.pop_back();
    while (vec.size()) _mul(res, k - 1), vec.pop_back();
    return res;
  }
  for (int i = 0; i < 2; i++, reverse(vec.begin(), vec.end()))
    while (vec.size() && vec.back() == -1) _mul(res, k - 1), vec.pop_back();
  int last = -1;
  for (int i = 0; i < vec.size(); i++)
    if (vec[i] != -1) {
      if (last != -1) {
        if (vec[last] == vec[i])
          _mul(res, same[i - last - 1]);
        else
          _mul(res, dif[i - last - 1]);
      }
      last = i;
    }
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  while (n--) {
    cin >> a;
    (n & 1 ? A : B).push_back(a);
  }
  calc_dp();
  cout << mul(solve(A), solve(B));
}
