#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 300 * 1000;
const long long MOD = 998244353;
long long n, k, dp[MAXN], A[MAXN], dpp[MAXN];
long long solve(long long a, long long b, long long d) {
  if (d == 0) return 1;
  for (long long i = 0; i < d; i++) dp[i] = 0, dpp[i] = 0;
  dp[0] = (a == -1);
  dpp[0] = 1;
  for (long long i = 1; i < d; i++) {
    dp[i] = (long long)dpp[i - 1] * (k - 1) % MOD;
    dpp[i] = ((long long)dpp[i - 1] * (k - 2) % MOD + dp[i - 1]) % MOD;
  }
  if (b == -1) return (dp[d - 1] + (long long)(k - 1) * dpp[d - 1]) % MOD;
  if (b) return (long long)dpp[d - 1] * (k - 1) % MOD;
  return ((long long)dpp[d - 1] * (k - 2) + dp[d - 1]) % MOD;
}
long long SolveMain(vector<long long> &vec) {
  vector<long long> all;
  long long ans = 1;
  for (long long i = 0; i < vec.size(); i++)
    if (vec[i] != -1) all.push_back(i);
  for (long long i = 0; i < vec.size() - 1; i++)
    if (vec[i] == vec[i + 1] && vec[i] != -1) return 0;
  if (all.empty()) return solve(-1, -1, vec.size());
  ans = (long long)ans * solve(1, -1, all[0]) % MOD;
  ans = (long long)ans * solve(1, -1, vec.size() - all.back() - 1) % MOD;
  for (long long i = 0; i < all.size() - 1; i++)
    ans = (long long)ans *
          solve(1, vec[all[i + 1]] == vec[all[i]], all[i + 1] - all[i] - 1) %
          MOD;
  return ans;
}
int32_t main() {
  cin >> n >> k;
  vector<long long> vec[2];
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
    vec[i % 2].push_back(A[i]);
  }
  cout << (long long)SolveMain(vec[0]) * SolveMain(vec[1]) % MOD;
}
