#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const int nax = 1e5 + 5;
const int MOD = 998244353;
int mul(int a, int b) {
  ll ret = 1LL * a * b;
  if (ret >= MOD) ret %= MOD;
  return ret;
}
int add(int a, int b) {
  int ret = a + b;
  if (ret >= MOD) ret -= MOD;
  return ret;
}
vvi arr(2, vi(nax)), ways(2, vi(nax));
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i & 1][i >> 1];
  }
  vi sz = {(n + 1) / 2, n / 2};
  arr[0][sz[0]] = arr[1][sz[1]] = k + 1;
  sz[0]++, sz[1]++;
  vi ans(2, 1);
  for (int i = 0; i < 2; i++) {
    int last = -1;
    ways[0][1] = 1, ways[1][1] = 1;
    for (int j = 1; j < sz[i]; j++) {
      if (arr[i][j] == -1) {
        if (arr[i][j - 1] == -1) {
          ways[0][j + 1] = mul((k - 1), ways[1][j]);
          ways[1][j + 1] = add(mul((k - 2), ways[1][j]), ways[0][j]);
        } else {
          ways[0][j + 1] = 0, ways[1][j + 1] = 1;
          last = arr[i][j - 1];
        }
      } else {
        if (arr[i][j] == arr[i][j - 1]) {
          ans[i] = 0;
          break;
        } else {
          if (arr[i][j - 1] == -1) {
            if (last == arr[i][j]) {
              ans[i] = mul(ans[i], mul((k - 1), ways[1][j]));
            } else {
              ans[i] = mul(ans[i], add(ways[0][j],
                                       mul((j == sz[i] - 1 ? (k - 1) : (k - 2)),
                                           ways[1][j])));
            }
          }
          last = arr[i][j];
        }
      }
    }
    if (!ans[i]) break;
  }
  cout << mul(ans[0], ans[1]);
}
