#include <bits/stdc++.h>
using namespace std;
long long solve(long long st, long long end, long long len, long long k) {
  long long dp[2][len];
  dp[0][0] = k - 1;
  dp[1][0] = 1;
  if (st == end and st != -1) {
    dp[1][0]--;
  } else if (st != -1) {
    dp[0][0]--;
  }
  if (len == 1) {
    long long ans = k;
    if (st != -1) {
      ans--;
    }
    if (end != -1) {
      ans--;
    }
    if (st == end and st != -1) {
      ans++;
    }
    return ans;
  }
  for (long long i = 1; i < len; i++) {
    dp[0][i] = (dp[0][i - 1] * (k - 2)) + (dp[1][i - 1] * (k - 1));
    dp[0][i] %= 998244353;
    dp[1][i] = (dp[0][i - 1]) % 998244353;
  }
  long long ans = dp[0][len - 1];
  if (end == -1) {
    ans += dp[1][len - 1];
    ans %= 998244353;
  }
  return ans;
}
long long solve_main(vector<long long> v, long long k) {
  long long ans = 1;
  long long len = 0;
  bool found = false;
  long long st = -1;
  for (long long i = 0; i < v.size(); i++) {
    if (v[i] != -1) {
      if (found) {
        long long curr = solve(st, v[i], len, k);
        ans *= curr;
        ans %= 998244353;
      }
      len = 0;
      st = v[i];
      found = false;
    } else {
      found = true;
      len++;
    }
  }
  if (len) {
    long long curr = solve(st, -1, len, k);
    ans *= curr;
    ans %= 998244353;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  bool ans = true;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    if (i > 1 and v[i] == v[i - 2] and v[i] != -1) {
      ans = false;
    }
  }
  if (!ans) {
    cout << 0 << "\n";
    return 0;
  }
  vector<long long> odd, even;
  for (long long i = 0; i < n; i += 2) {
    odd.push_back(v[i]);
  }
  for (long long i = 1; i < n; i += 2) {
    even.push_back(v[i]);
  }
  long long curr1 = solve_main(even, k);
  long long curr2 = solve_main(odd, k);
  long long final = (curr1 * curr2) % 998244353;
  cout << final << "\n";
}
