#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int add(int x, int y) {
  x += y;
  if (x < 0) x += MOD;
  if (x >= MOD) x -= MOD;
  return x;
}
int mult(int x, int y) { return (long long)x * y % MOD; }
int n, k;
int dp[200005][2];
int p[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> k;
  vector<int> a1, a2;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    if (i % 2 == 1) {
      a1.push_back(a);
    } else {
      a2.push_back(a);
    }
  }
  p[0] = 1;
  for (int i = 1; i < 200005; ++i) {
    p[i] = mult(p[i - 1], k - 1);
  }
  dp[0][0] = 1;
  for (int i = 1; i < 200005; ++i) {
    for (int j = 0; j < 2; ++j) {
      dp[i][j] = add(p[i], -dp[i - 1][j]);
    }
  }
  long long ans = 0;
  {
    int lef = 0, rig = (int)a1.size() - 1;
    while (lef < (int)a1.size() && a1[lef] == -1) ++lef;
    if (lef != (int)a1.size()) {
      while (a1[rig] == -1) --rig;
      long long cur = mult(p[lef], p[(int)a1.size() - rig - 1]);
      for (int i = 0; i < (int)a1.size(); ++i) {
        if (a1[i] != -1) {
          int end = i + 1;
          while (end < (int)a1.size() && a1[end] == -1) ++end;
          if (end == (int)a1.size()) break;
          int nxt;
          if (a1[i] == a1[end]) {
            nxt = dp[end - i - 1][1];
          } else {
            nxt = dp[end - i - 1][0];
          }
          cur = mult(cur, nxt);
        }
      }
      ans = cur;
    } else {
      ans = mult(k, p[(int)a1.size() - 1]);
    }
  }
  {
    int lef = 0, rig = (int)a2.size() - 1;
    while (lef < (int)a2.size() && a2[lef] == -1) ++lef;
    if (lef != (int)a2.size()) {
      while (a2[rig] == -1) --rig;
      long long cur = mult(p[lef], p[(int)a2.size() - rig - 1]);
      for (int i = 0; i < (int)a2.size(); ++i) {
        if (a2[i] != -1) {
          int end = i + 1;
          while (end < (int)a2.size() && a2[end] == -1) ++end;
          if (end == (int)a2.size()) break;
          int nxt;
          if (a2[i] == a2[end]) {
            nxt = dp[end - i - 1][1];
          } else {
            nxt = dp[end - i - 1][0];
          }
          cur = mult(cur, nxt);
        }
      }
      ans = mult(ans, cur);
    } else {
      ans = mult(ans, mult(k, p[(int)a2.size() - 1]));
    }
  }
  cout << ans << '\n';
  return 0;
}
