#include <bits/stdc++.h>
using namespace std;
template <typename T>
void _dbg(const char* second, T h) {
  cerr << second << " = " << h << '\n';
}
template <typename T, typename... Ts>
void _dbg(const char* second, T h, Ts... t) {
  int b = 0;
  while ((b += (*second == '(') - (*second == ')')) != 0 || *second != ',')
    cerr << *second++;
  cerr << " = " << h << ", ";
  _dbg(second + 1, t...);
}
static const int _ML = 200;
char MEM[_ML << 20];
size_t ptr = 0;
void* operator new(size_t req) {
  assert((ptr += req) < (_ML << 20));
  return MEM + ptr - req;
}
void operator delete(void*) {}
struct init {
  init() {
    cin.tie(0);
    std::iostream::sync_with_stdio(0);
    cout << std::fixed << std::setprecision(10);
    cerr << std::fixed << std::setprecision(5);
  }
  ~init() {}
} init;
const int N = (int)3e5 + 17;
int n, k;
const long long MOD = 998244353;
int a[N];
long long dp[N][2];
bool read() {
  if (!(cin >> n >> k)) return false;
  for (long long i = 0; i < (n); ++i) cin >> a[i];
  return true;
}
long long process(int len, int L, int R) {
  if (R < L) swap(R, L);
  dp[0][0] = k - 1 - (L != -1 && L != R);
  dp[0][1] = (L == R ? 0 : 1);
  for (int i = 0; i < len; ++i) {
    dp[i + 1][1] = dp[i][0];
    dp[i + 1][0] = (k - 1) * (dp[i][0] + dp[i][1]) - dp[i][0];
    dp[i + 1][0] = (MOD + dp[i + 1][0] % MOD) % MOD;
  }
  return dp[len - 1][0];
}
void solve() {
  long long ans = 1;
  for (long long j = 0; j < (2); ++j) {
    vector<int> b;
    b.emplace_back(a[j]);
    for (int i = j; i + 2 < n; ++ ++i) {
      if (a[i] == a[i + 2] && a[i] != -1) {
        cout << 0 << '\n';
        return;
      }
      b.emplace_back(a[i + 2]);
    }
    if (count(b.begin(), b.end(), -1) == int((b).size())) {
      ans *= k;
      ans %= MOD;
      for (long long i = 0; i < (int((b).size()) - 1); ++i)
        ans *= (k - 1), ans %= MOD;
      continue;
    }
    for (int l = 0; l < int((b).size());)
      if (b[l] == -1) {
        int r = l;
        for (; r < int((b).size()) && b[r] == -1; ++r) {
        }
        ans *= process(r - l, (l == 0 ? -1 : b[l - 1]),
                       (r == int((b).size()) ? -1 : b[r]));
        ans %= MOD;
        l = r;
      } else {
        ++l;
      }
  }
  cout << ans << '\n';
}
int32_t main() {
  while (read()) solve();
  return 0;
}
