#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long MOD = 998244353;
int n, k;
vector<int> a, b;
long long ans[MAXN][3][5];
bool found[MAXN][3][5];
long long mul(long long a, long long b) { return (a * b) % MOD; }
long long dp(int pos, int last, int var) {
  if (pos == 1) return (last == 1) ? 1LL : 0LL;
  if (found[pos][last][var]) return ans[pos][last][var];
  found[pos][last][var] = true;
  ans[pos][last][var] = 0LL;
  for (int i = 0; i < var; ++i)
    if (last == 0 || i != last) {
      long long koef = 1;
      if (i == 0) koef = k - var + 1;
      if (last == 0 && i == 0) koef--;
      koef = max(koef, 0LL);
      ans[pos][last][var] =
          (ans[pos][last][var] + mul(dp(pos - 1, i, var), koef)) % MOD;
    }
  return ans[pos][last][var];
}
long long calc(const vector<int> &A) {
  vector<pair<int, int> > fixed;
  fixed.push_back(pair<int, int>(0, -1));
  for (int i = 0; i < A.size(); ++i) {
    if (A[i] != -1) {
      fixed.push_back(pair<int, int>(A[i], i));
    }
  }
  fixed.push_back(pair<int, int>(0, A.size()));
  long long tmpAns = 1LL;
  for (int i = 0; i < fixed.size() - 1; ++i) {
    int l = fixed[i].second, r = fixed[i + 1].second;
    if (fixed[i].first == 0 && fixed[i + 1].first == 0) {
      tmpAns = mul(tmpAns, k);
      for (int j = l + 2; j < r; ++j) tmpAns = mul(tmpAns, k - 1);
    } else if (fixed[i].first == 0 || fixed[i + 1].first == 0) {
      for (int j = l + 1; j < r; ++j) tmpAns = mul(tmpAns, k - 1);
    } else {
      if (A[l] == A[r]) {
        tmpAns = mul(tmpAns, dp(r - l + 1, 1, 2));
      } else {
        tmpAns = mul(tmpAns, dp(r - l + 1, 2, 3));
      }
    }
  }
  return tmpAns;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    if (i % 2)
      a.push_back(tmp);
    else
      b.push_back(tmp);
  }
  printf("%lld\n", mul(calc(a), calc(b)));
}
