#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> evens, odds, arr;
int n, k;
pair<int, int> calc(int len) {
  if (len == 0) return {0, 1};
  if (len & 1) {
    auto res = calc(len >> 1);
    return {
        add(mul(res.first, res.first), mul(k - 1, mul(res.second, res.second))),
        add(mul(2, mul(res.first, res.second)),
            mul(k - 2, mul(res.second, res.second)))};
  }
  auto res = calc(len - 1);
  return {mul(k - 1, res.second), add(res.first, mul(k - 2, res.second))};
}
int calcSeg(int l, int r) {
  if (r >= arr.size()) {
    int len = r - l - 1, cf = 1;
    if (l < 0) {
      len--, cf = k;
    }
    if (len == 0) return cf;
    auto res = calc(len - 1);
    return mul(cf, add(res.first, mul(k - 1, res.second)));
  }
  if (l < 0) {
    if (r - l == 1) return 1;
    auto res = calc(r - l - 2);
    return add(res.first, mul(k - 1, res.second));
  }
  auto res = calc(r - l - 1);
  return arr[l] == arr[r] ? res.first : res.second;
}
int solve() {
  int ans = 1, lst = -1;
  for (int i = 0; i <= arr.size() - 1; i++) {
    if (arr[i] == -1) continue;
    ans = mul(ans, calcSeg(lst, i));
    lst = i;
  }
  ans = mul(ans, calcSeg(lst, arr.size()));
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    if (i % 2 == 1) {
      odds.push_back(a);
    } else {
      evens.push_back(a);
    }
  }
  int ans, oddAns, evenAns;
  arr = evens;
  evenAns = solve();
  arr = odds;
  oddAns = solve();
  ans = mul(oddAns, evenAns);
  printf("%d\n", ans);
  return 0;
}
