#include <bits/stdc++.h>
using namespace std;
long long n, k;
const long long mxn = 2e5 + 1, md = 998244353;
map<array<long long, 2>, long long> mem;
set<long long> av;
long long dp(long long i, long long li, vector<long long>& a) {
  if (a[i] != -1) return (li != a[i] || a[i] == k + 2);
  if (mem.count({i, li})) return mem[{i, li}];
  long long ans = 0;
  for (long long x : av)
    if (x != li) (ans += dp(i + 1, x, a)) %= md;
  if (li > k)
    ans += dp(i + 1, k + 1, a) * (k - av.size() - (li == k + 1));
  else
    ans += dp(i + 1, k + 1, a) * (k - av.size());
  ans %= md;
  return mem[{i, li}] = ans;
}
long long process(vector<long long> a) {
  a.push_back(k + 2);
  reverse(a.begin(), a.end());
  a.push_back(k + 2);
  reverse(a.begin(), a.end());
  for (long long i = 0; i + 1 < a.size(); i++)
    if (a[i] != -1 && a[i] == a[i + 1]) return 0;
  long long ans = 1;
  for (long long i = 1; i + 1 < a.size(); i++) {
    if (a[i] != -1) continue;
    long long li = 0;
    mem.clear();
    av.clear();
    for (long long j = i; j < a.size(); j++) {
      if (a[j] != -1) break;
      li = j;
    }
    if (a[i - 1] <= k) av.insert(a[i - 1]);
    if (a[li + 1] <= k) av.insert(a[li + 1]);
    (ans *= dp(i, a[i - 1], a)) %= md;
    i = li;
  }
  return ans;
}
signed main() {
  cin >> n >> k;
  vector<long long> a(n);
  for (long long& x : a) cin >> x;
  vector<long long> e, o;
  for (long long i = 0; i < n; i++) {
    if (i & 1)
      o.push_back(a[i]);
    else
      e.push_back(a[i]);
  }
  cout << (process(o) * process(e)) % md;
  return 0;
}
