#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const long long INF = 1000000000;
template <class T>
T read(T &x) {
  char c;
  int flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag *= -1;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= flag;
  return x;
}
long long n, k;
long long dp[200005][3];
int a[200005];
int c[200005], b[200005];
int n1, n2;
long long pw(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
long long solve(long long l, long long r) {
  dp[l][0] = dp[l][1] = dp[l][2] = 0;
  if (l == 0) {
    dp[l + 1][0] = k - 1;
    dp[l + 1][1] = 1;
    for (int i = 2; i <= r; ++i) {
      if (b[i] == -1) {
        dp[i][0] = (dp[i - 1][0] * (k - 2) + dp[i - 1][1] * (k - 1)) % MOD;
        dp[i][1] = dp[i - 1][0] % MOD;
      } else {
        dp[i][1] = dp[i - 1][0];
      }
    }
    return dp[r][1];
  } else if (b[l] != b[r]) {
    dp[l][1] = 1;
    for (int i = l + 1; i <= r; ++i) {
      if (b[i] == -1) {
        dp[i][0] =
            (dp[i - 1][0] * (k - 3) % MOD + dp[i - 1][1] * (k - 2) % MOD +
             dp[i - 1][2] * (k - 2) % MOD) %
            MOD;
        dp[i][1] = (dp[i - 1][0] + dp[i - 1][2]) % MOD;
        dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      } else {
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      }
    }
    return dp[r][2];
  } else {
    dp[l][1] = 1;
    for (int i = l + 1; i <= r; ++i) {
      if (b[i] == -1) {
        dp[i][0] =
            (dp[i - 1][0] * (k - 2) % MOD + dp[i - 1][1] * (k - 1)) % MOD;
        dp[i][1] = dp[i - 1][0];
      } else {
        dp[i][0] = 0;
        dp[i][1] = dp[i - 1][0];
      }
    }
    return dp[r][1];
  }
}
long long solve2(long long l, long long r) {
  dp[l][0] = dp[l][1] = dp[l][2] = 0;
  if (l == 0) {
    dp[l + 1][0] = k - 1;
    dp[l + 1][1] = 1;
    for (int i = 2; i <= r; ++i) {
      if (c[i] == -1) {
        dp[i][0] = (dp[i - 1][0] * (k - 2) + dp[i - 1][1] * (k - 1)) % MOD;
        dp[i][1] = dp[i - 1][0] % MOD;
      } else {
        dp[i][1] = dp[i - 1][0];
      }
    }
    return dp[r][1];
  } else if (c[l] != c[r]) {
    dp[l][1] = 1;
    for (int i = l + 1; i <= r; ++i) {
      if (c[i] == -1) {
        dp[i][0] =
            (dp[i - 1][0] * (k - 3) % MOD + dp[i - 1][1] * (k - 2) % MOD +
             dp[i - 1][2] * (k - 2) % MOD) %
            MOD;
        dp[i][1] = (dp[i - 1][0] + dp[i - 1][2]) % MOD;
        dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      } else {
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      }
    }
    return dp[r][2];
  } else {
    dp[l][1] = 1;
    for (int i = l + 1; i <= r; ++i) {
      if (c[i] == -1) {
        dp[i][0] =
            (dp[i - 1][0] * (k - 2) % MOD + dp[i - 1][1] * (k - 1)) % MOD;
        dp[i][1] = dp[i - 1][0];
      } else {
        dp[i][0] = 0;
        dp[i][1] = dp[i - 1][0];
      }
    }
    return dp[r][1];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  memset(dp, 0, sizeof dp);
  ;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (i % 2 == 1)
      b[++n1] = a[i];
    else
      c[++n2] = a[i];
  }
  for (int i = 3; i <= n; ++i) {
    if (a[i] != -1 && a[i] == a[i - 2]) return cout << 0 << endl, 0;
  }
  long long ans = 1;
  for (int i = 1; i <= n1; ++i) {
    if (b[i] != -1) continue;
    int j = i;
    while (b[j + 1] == -1) j++;
    if (i == 1 && j == n1) {
      long long len = j - i + 1;
      ans = ans * k % MOD * pw(k - 1, len - 1) % MOD;
    } else if (i == 1) {
      long long len = j - i + 1;
      ans = ans * solve(0, j + 1) % MOD;
    } else if (j == n1) {
      long long len = j - i + 1;
      ans = ans * pw(k - 1, len) % MOD;
    } else {
      ans = ans * solve(i - 1, j + 1) % MOD;
    }
    i = j;
  }
  memset(dp, 0, sizeof dp);
  ;
  for (int i = 1; i <= n2; ++i) {
    if (c[i] != -1) continue;
    int j = i;
    while (c[j + 1] == -1) j++;
    if (i == 1 && j == n2) {
      long long len = j - i + 1;
      ans = ans * k % MOD * pw(k - 1, len - 1) % MOD;
    } else if (i == 1) {
      long long len = j - i + 1;
      ans = ans * solve2(0, j + 1) % MOD;
    } else if (j == n2) {
      long long len = j - i + 1;
      ans = ans * pw(k - 1, len) % MOD;
    } else {
      ans = ans * solve2(i - 1, j + 1) % MOD;
    }
    i = j;
  }
  assert(ans >= 0);
  cout << max(ans, 0LL) << endl;
  ;
}
