#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -1;     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     return x * f;   }   int n, k, a[201010];   long long f[201010][2];   long long power(long long x, long long p) {     long long res = 1;     while (p) {       if (p & 1) res = res * x % 998244353;       x = x * x % 998244353;       p >>= 1;     }     return res;   }   long long dp(int l, int r, int len) {     if (len == 0) {       if (l == r && l != 0 && r != 0) return 0;       return 1;     }     if (r == 0) {       return (l == 0 ? k : (k - 1)) * power(k - 1, len - 1) % 998244353;     }     for (int i = 0; i <= len; i++) f[i][0] = f[i][1] = 0;     if (l == 0)       f[0][0] = k - 1, f[0][1] = 1, len--;     else if (l == r)       f[0][1] = 1;     else       f[0][0] = 1;     for (int i = 1; i <= len; i++) {       f[i][0] =           (f[i][0] + f[i - 1][0] * (k - 2) + f[i - 1][1] * (k - 1)) % 998244353;       f[i][1] = f[i - 1][0];     }     return f[len][0];   }   int main() {     n = read(), k = read();     long long ans = 1;     for (int i = 1; i <= n; i++) a[i] = read();     int lst = -1;     for (int i = 1; i <= n + 2; i += 2)       if (a[i] != -1)         ans = ans * dp(a[lst], a[i], (i - lst) / 2 - 1) % 998244353, lst = i;     lst = 0;     for (int i = 2; i <= n + 2; i += 2)       if (a[i] != -1)         ans = ans * dp(a[lst], a[i], (i - lst) / 2 - 1) % 998244353, lst = i;     cout << ans;   }   