#include <bits/stdc++.h>
using namespace std;
int N, A[200005];
long long K, KP[200005], DP[200005][2];
long long sol(vector<long long>& V) {
  int n = (int)(V.size());
  long long rtn = 1;
  int l = -1, r = -1;
  for (int i = 0; i <= n - 1; i++)
    if (V[i] != -1) {
      l = i;
      break;
    }
  if (l == -1) return K * KP[n - 1] % 998244353;
  rtn = KP[l];
  for (int i = n - 1; i >= 0; i--)
    if (V[i] != -1) {
      r = i;
      break;
    }
  rtn = rtn * KP[n - 1 - r] % 998244353;
  int pr = l;
  for (int i = l + 1; i <= r; i++) {
    if (V[i] == -1) continue;
    if (V[i] == V[pr])
      rtn = (rtn * DP[i - pr + 1][1]) % 998244353;
    else
      rtn = (rtn * DP[i - pr + 1][0]) % 998244353;
    pr = i;
  }
  return rtn;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> A[i];
  KP[0] = 1;
  for (int i = 1; i <= N; i++) KP[i] = (KP[i - 1] * (K - 1)) % 998244353;
  DP[2][0] = 1;
  DP[2][1] = 0;
  DP[3][0] = K - 2;
  DP[3][1] = K - 1;
  for (int i = 4; i <= N; i++) {
    DP[i][0] = DP[i][1] =
        (K * KP[i - 3] % 998244353 - KP[i - 3] * 2 % 998244353) % 998244353;
    DP[i][0] = ((DP[i][0] + DP[i - 2][0]) % 998244353 + 998244353) % 998244353;
    DP[i][1] = ((DP[i][1] + DP[i - 2][1]) % 998244353 + 998244353) % 998244353;
  }
  for (int i = 3; i <= N; i++) {
    if (A[i] == -1 || A[i - 2] == -1) continue;
    if (A[i] == A[i - 2]) {
      cout << 0 << '\n';
      return 0;
    }
  }
  vector<long long> V[2];
  for (int i = 1; i <= N; i++) {
    V[i % 2].push_back(A[i]);
  }
  cout << sol(V[0]) * sol(V[1]) % 998244353 << '\n';
  return 0;
}
