#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200005];
long long dp[200005][2], f[200005];
long long Get(deque<int>& q) {
  if (q.empty()) return 1;
  long long x = 0, last, ans = 1;
  while (!q.empty()) {
    int ret = q.back();
    if (ret == -1)
      x++;
    else
      break;
    q.pop_back();
  }
  if (q.empty()) return f[x - 1] % 998244353;
  ans = ans * (dp[x][0] + dp[x][1] * (k - 1) % 998244353) % 998244353;
  x = 0;
  while (!q.empty()) {
    int ret = q.front();
    if (ret == -1)
      x++;
    else
      break;
    q.pop_front();
  }
  ans = ans * (dp[x][0] + dp[x][1] * (k - 1) % 998244353) % 998244353;
  while (!q.empty()) {
    x = 0;
    last = q.back();
    q.pop_back();
    while (!q.empty() && q.back() == -1) {
      x++;
      q.pop_back();
    }
    if (q.empty()) break;
    ans = ans *
          (q.back() == last ? dp[x][1] * (k - 1) % 998244353
                            : (dp[x][0] + dp[x][1] * (k - 2)) % 998244353) %
          998244353;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  deque<int> a[2];
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i & 1].push_back(x);
  }
  dp[0][0] = 1;
  dp[0][1] = 0;
  f[0] = k;
  for (int i = 1; i <= n; ++i) {
    long long ret = dp[i - 1][1] * (k - 1) % 998244353;
    dp[i][1] = (dp[i - 1][1] * (k - 2) + dp[i - 1][0]) % 998244353;
    dp[i][0] = ret;
    f[i] = (f[i - 1] * (k - 1)) % 998244353;
  }
  long long l = Get(a[0]);
  long long r = Get(a[1]);
  cout << (l * r) % 998244353;
  return 0;
}
