#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-11;
const int N = 200010;
const long long mod = 998244353LL;
int n, m, a[N];
bool check(const std::vector<int>& v) {
  for (int i = 1; i < v.size(); ++i)
    if (v[i - 1] == v[i] && v[i] != -1) return false;
  return true;
}
long long work(const std::vector<int>& v, const int l, const int r) {
  long long f[2][2];
  memset(f, 0, sizeof(f));
  int a = 0, b = 0, k = 0;
  if (l) a = v[l - 1];
  if (r != v.size())
    b = v[r], k = m - 2;
  else
    k = m - 1;
  int now = 0, pre = 1;
  f[now][0] = a ? m - 1 : m;
  f[now][1] = 0;
  if (b && b != a) {
    f[now][0]--;
    f[now][1]++;
  }
  int len = r - l;
  for (int i = 1; i < len; ++i) {
    swap(now, pre);
    f[now][0] = ((f[pre][0] * k % mod) + (f[pre][1] * (m - 1) % mod)) % mod;
    f[now][1] = b ? f[pre][0] : 0LL;
  }
  return f[now][0];
}
long long gao(const std::vector<int>& v) {
  long long ans = 1LL;
  int l = 0, r = 0, len = v.size();
  for (; r < len;) {
    if (v[l] != -1)
      l++, r = l;
    else {
      while (r < n && v[r] == -1) r++;
      long long tmp = work(v, l, r);
      ans = (ans * tmp) % mod;
      l = r;
    }
  }
  return ans;
}
void solve() {
  std::vector<int> ar[2];
  for (int i = 0; i < n; ++i) ar[i % 2].push_back(a[i]);
  if (!check(ar[0]) || !check(ar[1])) {
    puts("0");
    return;
  }
  long long ans[2] = {0LL, 0LL};
  for (int i = 0; i < 2; ++i) ans[i] = gao(ar[i]);
  std::cout << (ans[0] * ans[1]) % mod << std::endl;
}
int main() {
  while (scanf("%d%d", &(n), &(m)) != EOF) {
    for (int i = 0; i < n; ++i) scanf("%d", &(a[i]));
    solve();
  }
}
