#include <bits/stdc++.h>
using namespace std;
long long x[200050];
long long dp[200050];
long long dp_1 = 1, dp_1_sum = 1;
long long dp_2 = 1, dp_2_sum = 1;
long long ans[200050];
signed main() {
  ios::sync_with_stdio(false);
  ;
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> x[i];
  }
  if (x[1] > 0) {
    dp[1] = 0;
    dp_1 = x[1], dp_1_sum = 1;
  } else {
    dp[1] = 1;
    dp_1 = 1, dp_1_sum = 1;
  }
  for (long long i = 3; i <= n; i += 2) {
    if (x[i] > 0) {
      if (x[i] == dp_1) {
        dp_1_sum = (m - 1) * dp[i - 2] % 998244353;
      } else {
        dp_1_sum = ((m - 2) * dp[i - 2] % 998244353 + dp_1_sum) % 998244353;
      }
      dp_1 = x[i];
    } else {
      dp[i] = ((m - 2) * dp[i - 2] % 998244353 + dp_1_sum) % 998244353;
      dp_1_sum = (m - 1) * dp[i - 2] % 998244353;
    }
  }
  if (x[2] > 0) {
    dp[2] = 0;
    dp_2 = x[2], dp_2_sum = 1;
  } else {
    dp[2] = 1;
    dp_2 = 1, dp_2_sum = 1;
  }
  for (long long i = 4; i <= n; i += 2) {
    if (x[i] > 0) {
      if (x[i] == dp_2) {
        dp_2_sum = (m - 1) * dp[i - 2] % 998244353;
      } else {
        dp_2_sum = ((m - 2) * dp[i - 2] % 998244353 + dp_2_sum) % 998244353;
      }
      dp_2 = x[i];
    } else {
      dp[i] = ((m - 2) * dp[i - 2] % 998244353 + dp_2_sum) % 998244353;
      dp_2_sum = (m - 1) * dp[i - 2] % 998244353;
    }
  }
  long long ans;
  if (n % 2 == 0) {
    ans = (dp_1_sum + (m - 1) * dp[n - 1] % 998244353) *
          (dp_2_sum + (m - 1) * dp[n] % 998244353) % 998244353;
  } else {
    ans = (dp_1_sum + (m - 1) * dp[n] % 998244353) *
          (dp_2_sum + (m - 1) * dp[n - 1] % 998244353) % 998244353;
  }
  cout << ans;
  return 0;
}
