#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long, vector<long long>, greater<long long>>
    minHeap;
const int INF = 1e9 + 9;
const long long LINF = 1e17 + 9;
const long long MD = 998244353;
inline long long po(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % MD;
    a = (a * a) % MD;
    b /= 2;
  }
  return ans;
}
const int N = 2e5 + 33;
long long n, m, k, t;
long long arr[N];
string s;
long long dif[N], same[N];
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  cout << fixed;
  cout << setprecision(7);
  cerr << "N"
       << " is " << N << endl;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  dif[0] = 1;
  for (int i = 1; i < n; i++) {
    if (i & 1) {
      same[i] = (po(same[i / 2], 2) + (po(dif[i / 2], 2) * (k - 1)) % MD) % MD;
      dif[i] = (2ll * (same[i / 2] * dif[i / 2]) +
                (po(dif[i / 2], 2) * (k - 2)) % MD) %
               MD;
    } else {
      same[i] = ((same[i / 2] * same[i / 2 - 1]) % MD +
                 (((dif[i / 2] * dif[i / 2 - 1]) % MD) * (k - 1)) % MD) %
                MD;
      dif[i] =
          ((same[i / 2 - 1] * dif[i / 2]) + (same[i / 2] * dif[i / 2 - 1]) +
           (((dif[i / 2] * dif[i / 2 - 1]) % MD) * (k - 2)) % MD) %
          MD;
    }
  }
  long long ans = 1;
  int last = -1, l = 0;
  for (int i = 0; i < n; i += 2) {
    if (~arr[i]) {
      if (~last) {
        if (last == arr[i])
          ans = (ans * same[l]) % MD;
        else
          ans = (ans * dif[l]) % MD;
      } else {
        if (l > 0)
          ans = (ans * (((k - 1) * dif[l - 1] + same[l - 1]) % MD)) % MD;
      }
      l = 0;
      last = arr[i];
    } else {
      l++;
    }
  }
  if (~last) {
    if (l > 0) ans = (ans * (((k - 1) * dif[l - 1] + same[l - 1]) % MD)) % MD;
  } else {
    ans = (ans * ((po(k - 1, l - 1) * k) % MD)) % MD;
  }
  last = -1, l = 0;
  for (int i = 1; i < n; i += 2) {
    if (~arr[i]) {
      if (~last) {
        if (last == arr[i])
          ans = (ans * same[l]) % MD;
        else
          ans = (ans * dif[l]) % MD;
      } else {
        if (l > 0)
          ans = (ans * (((k - 1) * dif[l - 1] + same[l - 1]) % MD)) % MD;
      }
      l = 0;
      last = arr[i];
    } else {
      l++;
    }
  }
  if (~last) {
    if (l > 0) ans = (ans * (((k - 1) * dif[l - 1] + same[l - 1]) % MD)) % MD;
  } else {
    ans = (ans * ((po(k - 1, l - 1) * k) % MD)) % MD;
  }
  cout << ans;
  return 0;
}
