#include <bits/stdc++.h>
using namespace std;
long long n, k;
const long long MOD = 998244353;
const long long MAXN = 3e5 + 5;
vector<long long> v1[3];
long long cntsame[MAXN];
long long cntdiff[MAXN];
void precomp() {
  cntdiff[0] = 1;
  for (long long i = 1; i <= n; i++) {
    if (i % 2) {
      cntsame[i] =
          (cntsame[i / 2] % MOD * cntsame[i / 2] % MOD) +
          (cntdiff[i / 2] % MOD * cntdiff[i / 2] % MOD * (k - 1)) % MOD;
      cntdiff[i] =
          (2 * cntsame[i / 2] % MOD * cntdiff[i / 2] % MOD) +
          ((k - 2) % MOD * (cntdiff[i / 2] % MOD * cntdiff[i / 2] % MOD)) % MOD;
    } else {
      cntsame[i] = (cntdiff[i - 1] % MOD * (k - 1)) % MOD;
      cntdiff[i] =
          (cntsame[i - 1] % MOD + cntdiff[i - 1] % MOD * (k - 2)) % MOD;
    }
  }
}
long long solveeven() {
  long long curr = 0;
  long long l = -1;
  long long ans = 1;
  for (long long i = 0; i < v1[0].size(); i++) {
    long long tempans = 0;
    if (curr && v1[0][i] != -1) {
      if (l == -1) {
        curr--;
        tempans += (cntsame[curr] % MOD);
        tempans %= MOD;
        tempans += (k - 1) * (cntdiff[curr]) % MOD;
        tempans %= MOD;
        curr = 0;
        l = v1[0][i];
      } else {
        if (l == v1[0][i]) {
          tempans += cntsame[curr] % MOD;
          tempans %= MOD;
          curr = 0;
          l = v1[0][i];
        } else {
          tempans += cntdiff[curr] % MOD;
          tempans %= MOD;
          l = v1[0][i];
          curr = 0;
        }
      }
      ans *= tempans;
      ans %= MOD;
    } else if (v1[0][i] == -1) {
      curr++;
    } else if (v1[0][i] != -1) {
      l = v1[0][i];
    }
    if (i && v1[0][i] == v1[0][i - 1] && v1[0][i] != -1) {
      return 0;
    }
  }
  if (curr) {
    long long tempans = 0;
    if (l == -1) {
      if (curr == 1) {
        tempans += k;
        tempans %= MOD;
      } else {
        tempans += ((k) % MOD * (k - 1) % MOD * cntdiff[curr - 2] % MOD) % MOD;
        tempans %= MOD;
        tempans += ((k) % MOD * (cntsame[curr - 2]) % MOD) % MOD;
        tempans %= MOD;
      }
    } else {
      curr--;
      tempans += cntsame[curr] % MOD;
      tempans %= MOD;
      tempans += (k - 1) % MOD * cntdiff[curr] % MOD;
      tempans %= MOD;
    }
    ans *= tempans;
    ans %= MOD;
  }
  return ans;
}
long long solveodd() {
  long long curr = 0;
  long long l = -1;
  long long ans = 1;
  for (long long i = 0; i < v1[1].size(); i++) {
    long long tempans = 0;
    if (curr && v1[1][i] != -1) {
      if (l == -1) {
        curr--;
        tempans += cntsame[curr] % MOD;
        tempans += (k - 1) % MOD * cntdiff[curr] % MOD;
        tempans %= MOD;
        curr = 0;
        l = v1[1][i];
      } else {
        if (l == v1[1][i]) {
          tempans += cntsame[curr] % MOD;
          tempans %= MOD;
          curr = 0;
          l = v1[1][i];
        } else {
          tempans += cntdiff[curr] % MOD;
          tempans %= MOD;
          l = v1[1][i];
          curr = 0;
        }
      }
      ans *= tempans;
      ans %= MOD;
    } else if (v1[1][i] == -1) {
      curr++;
    } else if (v1[1][i] != -1) {
      l = v1[1][i];
    }
    if (i && v1[1][i] == v1[1][i - 1] && v1[1][i] != -1) {
      return 0;
    }
  }
  if (curr) {
    long long tempans = 0;
    if (l == -1) {
      if (curr == 1) {
        tempans += k;
      } else {
        tempans += (k) % MOD * (k - 1) % MOD * (cntdiff[curr - 2] % MOD);
        tempans %= MOD;
        tempans += (k) * ((cntsame[curr - 2]) % MOD);
        tempans %= MOD;
      }
    } else {
      curr--;
      tempans += cntsame[curr] % MOD;
      tempans %= MOD;
      tempans += (k - 1) * (cntdiff[curr] % MOD);
      tempans %= MOD;
    }
    ans *= tempans;
    ans %= MOD;
  }
  ans %= MOD;
  return ans;
}
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    v1[i % 2].push_back(x);
  }
  precomp();
  cout << solveeven() * (solveodd()) % MOD << endl;
}
