#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int mod = 998244353;
int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
int mul(int x, int y) {
  x = (long long)x * y % mod;
  return x;
}
vector<int> odds, evens;
int n, k, res[N];
int calc(vector<int> v) {
  long long x, y;
  int n = v.size();
  int a, i;
  x = 1;
  for (i = 0; i < n && v[i] == -1; i++) {
    if (i == 0) {
      continue;
    } else {
      x = mul(x, k - 1);
    }
  }
  y = x;
  a = 0;
  for (; i < n; i++) {
    long long xnew = mul(y, k - 1);
    long long ynew = add(x, mul(y, k - 2));
    if (v[i] == -1) {
      x = xnew;
      y = ynew;
    } else {
      if (i == 0) {
        x = 1;
        y = 0;
      } else {
        if (v[i] == a) {
          x = xnew;
        } else {
          x = ynew;
        }
        y = 0;
      }
      a = v[i];
    }
  }
  return add(x, mul(y, k - 1));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    if (i % 2 == 0) {
      evens.push_back(a);
    } else {
      odds.push_back(a);
    }
  }
  int ans = mul(calc(evens), calc(odds));
  printf("%d\n", ans);
  return 0;
}
