#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[100009], b[100009], la, lb;
long long dp[100009][2], suma, sumb;
int o;
int main() {
  scanf("%d%d", &n, &k);
  for (int j = 1; j <= n; j++) {
    if (j % 2)
      scanf("%d", &a[j / 2 + 1]);
    else
      scanf("%d", &b[j / 2]);
  }
  la = n / 2;
  if (n % 2) la++;
  lb = n / 2;
  o = 1;
  while (o <= la && a[o] == -1) o++;
  if (a[1] == -1) {
    if (o <= la) {
      if (o == 2) {
        dp[1][1] = 0;
        dp[1][0] = k - 1;
      } else {
        dp[1][1] = 1;
        dp[1][0] = k - 1;
      }
    } else {
      dp[1][1] = 0;
      dp[1][0] = k;
    }
  } else {
    dp[1][1] = 0;
    dp[1][0] = 1;
  }
  for (int j = 2; j <= la; j++) {
    if (a[j] != -1 && a[j] == a[j - 1]) {
      printf("0");
      return 0;
    }
    if (a[j] != -1) {
      dp[j][0] = dp[j - 1][0];
      dp[j][1] = dp[j - 1][1];
    } else {
      if (o < j) {
        o = j + 1;
        while (o <= la && a[o] == -1) o++;
      }
      if (o > la) {
        dp[j][1] = 0;
        dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 1) % 998244353;
      } else if (j + 1 == o) {
        dp[j][1] = 0;
        if (a[j - 1] == -1)
          dp[j][0] =
              (dp[j - 1][1] * (k - 1) + dp[j - 1][0] * (k - 2)) % 998244353;
        else if (a[j - 1] == a[j + 1])
          dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 1) % 998244353;
        else
          dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 2) % 998244353;
      } else if (a[j - 1] == -1) {
        dp[j][1] = dp[j - 1][0];
        dp[j][0] =
            (dp[j - 1][1] * (k - 1) + dp[j - 1][0] * (k - 2)) % 998244353;
      } else if (a[j - 1] == a[o]) {
        dp[j][1] = 0;
        dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 1) % 998244353;
      } else {
        dp[j][1] = (dp[j - 1][1] + dp[j - 1][0]) % 998244353;
        dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 2) % 998244353;
      }
    }
  }
  suma = dp[la][1] + dp[la][0];
  memset(dp, 0, sizeof(dp));
  o = 1;
  while (o <= lb && b[o] == -1) o++;
  if (b[1] == -1) {
    if (o <= lb) {
      if (o == 2) {
        dp[1][1] = 0;
        dp[1][0] = k - 1;
      } else {
        dp[1][1] = 1;
        dp[1][0] = k - 1;
      }
    } else {
      dp[1][1] = 0;
      dp[1][0] = k;
    }
  } else {
    dp[1][1] = 0;
    dp[1][0] = 1;
  }
  for (int j = 2; j <= lb; j++) {
    if (b[j] != -1 && b[j] == b[j - 1]) {
      printf("0");
      return 0;
    }
    if (b[j] != -1) {
      dp[j][0] = dp[j - 1][0];
      dp[j][1] = dp[j - 1][1];
    } else {
      if (o < j) {
        o = j + 1;
        while (o <= lb && b[o] == -1) o++;
      }
      if (o > lb) {
        dp[j][1] = 0;
        dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 1) % 998244353;
      } else if (j + 1 == o) {
        dp[j][1] = 0;
        if (b[j - 1] == -1)
          dp[j][0] =
              (dp[j - 1][1] * (k - 1) + dp[j - 1][0] * (k - 2)) % 998244353;
        else if (b[j - 1] == b[j + 1])
          dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 1) % 998244353;
        else
          dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 2) % 998244353;
      } else if (b[j - 1] == -1) {
        dp[j][1] = dp[j - 1][0];
        dp[j][0] =
            (dp[j - 1][1] * (k - 1) + dp[j - 1][0] * (k - 2)) % 998244353;
      } else if (b[j - 1] == b[o]) {
        dp[j][1] = 0;
        dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 1) % 998244353;
      } else {
        dp[j][1] = (dp[j - 1][1] + dp[j - 1][0]) % 998244353;
        dp[j][0] = (dp[j - 1][1] + dp[j - 1][0]) * (k - 2) % 998244353;
      }
    }
  }
  sumb = dp[lb][1] + dp[lb][0];
  printf("%lld", suma * sumb % 998244353);
  return 0;
}
