#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int mod = 998244353;
long long ans, dp[N][2], n, m, i, a[N], fix[N];
vector<pair<int, int> > V;
void go(int L, int bef, int aft) {
  if (bef < 1 && aft > n) {
    for (int k = 1; k < L; k++) ans = ans * (m - 1) % mod;
    ans = ans * m % mod;
  } else if (bef < 1 || aft > n) {
    for (int k = 1; k <= L; k++) ans = ans * (m - 1) % mod;
  } else {
    if (a[bef] == a[aft])
      dp[bef][0] = 0, dp[bef][1] = 1;
    else
      dp[bef][1] = 0, dp[bef][0] = 1;
    for (int j = bef + 2; j <= aft - 2; j += 2) {
      dp[j][1] = dp[j - 2][0];
      dp[j][0] = dp[j - 2][1] * (m - 1) % mod + dp[j - 2][0] * (m - 2) % mod;
      dp[j][0] %= mod;
    }
    ans = ans *
          ((dp[aft - 4][0] * (m - 2) % mod + dp[aft - 4][1] * (m - 1) % mod) %
           mod) %
          mod;
  }
}
int main() {
  cin >> n >> m;
  ans = 1;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (i > 1 && a[i] == a[i - 2] && a[i] != -1) ans = 0;
  }
  for (i = 1; i <= n; i++) {
    if (fix[i]) continue;
    if (a[i] != -1) continue;
    int j = i;
    while (j + 2 <= n && a[j + 2] == -1) j += 2, fix[j] = 1;
    V.push_back({i, j});
  }
  for (i = 0; i < V.size(); i++) {
    int sz = (V[i].second - V[i].first + 2) / 2;
    go(sz, V[i].first - 2, V[i].second + 2);
  }
  cout << ans;
}
