func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int n, k;   vector<long long int> od, ev;   long long int dps[200005], dpd[200005];   void buildDp() {     dps[0] = 0LL;     dps[1] = k - 1;     dpd[0] = 1LL;     dpd[1] = k - 2;     for (int i = 2; i < 200005; i++) {       dps[i] = ((dps[i - 2] * (k - 1)) % 998244353LL +                 ((dps[i - 1] * (k - 2)) % 998244353LL)) %                998244353LL;       dpd[i] = ((dpd[i - 2] * (k - 1)) % 998244353LL +                 ((dpd[i - 1] * (k - 2)) % 998244353LL)) %                998244353LL;     }   }   vector<pair<long long int, int>> p;   long long int solve(vector<long long int> v) {     p.clear();     long long int ans = 1LL;     int vz = (int)v.size();     if (vz == 0) return 1LL;     for (int i = 0; i < vz; i++)       if (v[i] != -1) p.push_back(make_pair(v[i], i));     int pz = (int)p.size();     if (pz > 0) {       long long int nf = p[0].second;       long long int nb = vz - 1 - p[pz - 1].second;       for (int i = 0; i < nf; i++) ans = (ans * (k - 1)) % 998244353LL;       for (int i = 0; i < nb; i++) ans = (ans * (k - 1)) % 998244353LL;       if (pz >= 2) {         for (int i = 0; i < pz - 1; i++) {           int gap = p[i + 1].second - p[i].second - 1;           if (p[i].first == p[i + 1].first)             ans = (ans * dps[gap]) % 998244353LL;           else             ans = (ans * dpd[gap]) % 998244353LL;         }       }     } else {       ans = k;       for (int i = 0; i < vz - 1; i++) ans = (ans * (k - 1)) % 998244353LL;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(0);     ;     cin >> n >> k;     for (int i = 0; i < n; i++) {       long long int temp;       cin >> temp;       if (i & 1LL)         od.push_back(temp);       else         ev.push_back(temp);     }     buildDp();     cout << (solve(ev) * solve(od)) % 998244353LL;     return 0;   }   