#include <bits/stdc++.h>
using namespace std;
long long n, k, anw;
long long ds[200005], dd[200005];
const long long MOD = 998244353;
vector<long long> odd, even;
long long get(vector<long long> a) {
  if (a.size() == 1) {
    if (a[0] == -1)
      return k % MOD;
    else
      return 1;
  }
  long long ret = 1;
  dd[0] = 1, dd[1] = k - 2;
  ds[0] = 0, ds[1] = k - 1;
  for (int i = 2; i <= n; i++) {
    ds[i] = ((k - 2) * ds[i - 1] + (k - 1) * ds[i - 2]) % MOD;
    dd[i] = ((k - 2) * dd[i - 1] + (k - 1) * dd[i - 2]) % MOD;
  }
  vector<long long> ar;
  for (int i = 0; i < a.size(); i++)
    if (a[i] != -1) ar.push_back(i);
  long long l = ar.size();
  if (l == 0)
    ret *= k * ds[a.size() - 2] + k * (k - 1) * dd[a.size() - 2], ret %= MOD;
  else {
    for (int i = 1; i < l; i++) {
      if (a[ar[i]] == a[ar[i - 1]])
        ret *= ds[(ar[i] - ar[i - 1] - 1)];
      else
        ret *= dd[(ar[i] - ar[i - 1] - 1)];
      ret %= MOD;
    }
    if (a[0] == -1)
      ret *= ((k - 1) * dd[ar[0] - 1] + ds[ar[0] - 1]) % MOD, ret %= MOD;
    if (a[a.size() - 1] == -1)
      ret *= (ds[a.size() - 1 - ar[ar.size() - 1] - 1] % MOD +
              (k - 1) * dd[a.size() - 1 - ar[ar.size() - 1] - 1]) %
             MOD,
          ret %= MOD;
  }
  return ret % MOD;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (i % 2)
      odd.push_back(a);
    else
      even.push_back(a);
  }
  cout << (get(even) * get(odd)) % MOD;
  return 0;
}
