#include <bits/stdc++.h>
using namespace std;
inline long long fpow(long long n, long long k, int p = 998244353) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
inline int inv(int a, int p = 998244353) { return fpow(a, p - 2, p); }
inline int addmod(int a, int val, int p = 998244353) {
  {
    if ((a = (a + val)) >= p) a -= p;
  }
  return a;
}
inline int submod(int a, int val, int p = 998244353) {
  {
    if ((a = (a - val)) < 0) a += p;
  }
  return a;
}
inline int mult(int a, int b, int p = 998244353) {
  return (long long)a * b % p;
}
vector<long long> cntS(200005, 0), cntD(200005, 0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  cntS[0] = 0;
  cntD[0] = 1;
  for (int i = 1; i <= n; i++)
    if (i % 2) {
      cntS[i] = addmod(fpow(cntS[i / 2], 2), mult(k - 1, fpow(cntD[i / 2], 2)));
      cntD[i] = addmod(mult(2, mult(cntS[i / 2], cntD[i / 2])),
                       mult(k - 2, fpow(cntD[i / 2], 2)));
    } else {
      cntS[i] = mult(k - 1, cntD[i - 1]);
      cntD[i] = addmod(cntS[i - 1], mult(k - 2, cntD[i - 1]));
    }
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> b[i];
  int l = INT_MIN;
  int r = INT_MAX;
  int res = 1;
  int cnt = 0;
  for (int i = 0; i < n; i += 2)
    if (b[i] == -1)
      cnt++;
    else {
      r = b[i];
      if (l == INT_MIN) {
        if (cnt > 0)
          res = mult(res, addmod(mult(k - 1, cntD[cnt - 1]), cntS[cnt - 1]));
      } else {
        if (l == r)
          res = mult(res, cntS[cnt]);
        else
          res = mult(res, cntD[cnt]);
      }
      cnt = 0;
      l = b[i];
    }
  if (cnt != 0)
    if (l == INT_MIN) {
      if (cnt > 1)
        res = mult(res, addmod(mult(mult(k, k - 1), cntD[cnt - 2]),
                               mult(k, cntS[cnt - 2])));
      else
        res = mult(res, k);
    } else
      res = mult(res, addmod(mult(k - 1, cntD[cnt - 1]), cntS[cnt - 1]));
  l = INT_MIN;
  r = INT_MAX;
  cnt = 0;
  for (int i = 1; i < n; i += 2)
    if (b[i] == -1)
      cnt++;
    else {
      r = b[i];
      if (l == INT_MIN) {
        if (cnt > 0)
          res = mult(res, addmod(mult(k - 1, cntD[cnt - 1]), cntS[cnt - 1]));
      } else {
        if (l == r)
          res = mult(res, cntS[cnt]);
        else
          res = mult(res, cntD[cnt]);
      }
      cnt = 0;
      l = b[i];
    }
  if (cnt != 0)
    if (l == INT_MIN) {
      if (cnt > 1)
        res = mult(res, addmod(mult(mult(k, k - 1), cntD[cnt - 2]),
                               mult(k, cntS[cnt - 2])));
      else
        res = mult(res, k);
    } else
      res = mult(res, addmod(mult(k - 1, cntD[cnt - 1]), cntS[cnt - 1]));
  cout << res << '\n';
  return 0;
}
