#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int mod = 998244353;
int n, k;
int ans = 1;
int arr[N];
int memo[N][2];
inline int mul(int a, int b) { return (1ll * a * b) % mod; }
inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int dp(int len, int t) {
  if (len == 0) {
    return (t ? 1 : 0);
  }
  if (memo[len][t] != -1) return memo[len][t];
  int ans = 0;
  if (len & 1) {
    if (t) {
      int here = mul(dp(len / 2, 1), dp(len / 2, 0));
      add(ans, mul(here, 2));
      here = mul(dp(len / 2, 1), dp(len / 2, 1));
      add(ans, mul(here, k - 2));
    } else {
      add(ans, mul(dp(len / 2, 0), dp(len / 2, 0)));
      int here = mul(dp(len / 2, 1), dp(len / 2, 1));
      add(ans, mul(here, k - 1));
    }
  } else {
    if (t) {
      add(ans, dp(len - 1, 0));
      add(ans, mul(dp(len - 1, 1), k - 2));
    } else {
      add(ans, mul(dp(len - 1, 1), k - 1));
    }
  }
  return memo[len][t] = ans;
}
int main() {
  cin >> n >> k;
  memset(memo, -1, sizeof memo);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i += 2) {
    int cur = 0, p = i;
    while (arr[i] == -1) {
      i += 2;
      cur++;
    }
    if (p == 0 && i >= n) {
      ans = mul(ans, k);
      for (int j = 2; j <= cur; j++) {
        ans = mul(ans, k - 1);
      }
    } else if (p == 0 || i >= n) {
      for (int j = 1; j <= cur; j++) {
        ans = mul(ans, k - 1);
      }
    } else {
      int fst = arr[p - 2], lst = arr[i];
      ans = mul(ans, dp(cur, (fst == lst ? 0 : 1)));
    }
  }
  for (int i = 1; i < n; i += 2) {
    int cur = 0, p = i;
    while (arr[i] == -1) {
      i += 2;
      cur++;
    }
    if (p == 1 && i >= n) {
      ans = mul(ans, k);
      for (int j = 2; j <= cur; j++) {
        ans = mul(ans, k - 1);
      }
    } else if (p == 1 || i >= n) {
      for (int j = 1; j <= cur; j++) {
        ans = mul(ans, k - 1);
      }
    } else {
      int fst = arr[p - 2], lst = arr[i];
      ans = mul(ans, dp(cur, (fst == lst ? 0 : 1)));
    }
  }
  cout << ans << endl;
  return 0;
}
