#include <bits/stdc++.h>
using namespace std;
int n;
long long int k;
long long int a[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int ans = 1;
  int st = -1, en = -1;
  for (int i = 0; i < n; i += 2) {
    if (a[i] == -1) {
      if (st == -1) {
        en = i;
        st = i;
      } else
        en += 2;
    } else {
      if (st != -1) {
        if (st == en) {
          if (st > 1 && en < n - 2) {
            if (a[st - 2] == a[en + 2])
              ans = ans * (k - 1);
            else
              ans = ans * (k - 2);
          } else if (st <= 1 && en >= n - 2)
            ans = ans * (k);
          else
            ans = ans * (k - 1);
        } else {
          long long int cur1, cur0, la1, la0;
          if (st > 1 && en < n - 2) {
            long long int v1 = a[st - 2];
            long long int v2 = a[en + 2];
            if (v1 == v2) {
              la1 = 0;
              la0 = k - 1;
            } else {
              la1 = 1;
              la0 = k - 2;
            }
            for (int j = st + 2; j <= en; j += 2) {
              cur1 = la0;
              cur0 = la1 * (k - 1) + la0 * (k - 2);
              la0 = cur0;
              la1 = cur1;
              if (la0 >= 998244353) la0 %= 998244353;
              if (la1 >= 998244353) la1 %= 998244353;
            }
            ans = ans * la0;
          } else {
            long long int cur;
            if (st <= 1 && en >= n - 2)
              cur = k;
            else
              cur = k - 1;
            for (int j = st + 2; j <= en; j += 2) {
              cur = cur * (k - 1);
              if (cur >= 998244353) cur %= 998244353;
            }
            ans *= cur;
          }
        }
      } else {
        if (i > 1 && a[i - 2] == a[i]) ans = 0;
        if (i < n - 2 && a[i + 2] == a[i]) ans = 0;
      }
      st = -1, en = -1;
    }
    if (ans >= 998244353) ans %= 998244353;
  }
  if (st != -1) {
    if (st == en) {
      if (st > 1 && en < n - 2) {
        if (a[st - 2] == a[en + 2])
          ans = ans * (k - 1);
        else
          ans = ans * (k - 2);
      } else if (st <= 1 && en >= n - 2)
        ans = ans * (k);
      else
        ans = ans * (k - 1);
    } else {
      long long int cur1, cur0, la1, la0;
      if (st > 1 && en < n - 2) {
        long long int v1 = a[st - 2];
        long long int v2 = a[en + 2];
        if (v1 == v2) {
          la1 = 0;
          la0 = k - 1;
        } else {
          la1 = 1;
          la0 = k - 2;
        }
        for (int j = st + 2; j <= en; j += 2) {
          cur1 = la0;
          cur0 = la1 * (k - 1) + la0 * (k - 2);
          la0 = cur0;
          la1 = cur1;
          if (la0 >= 998244353) la0 %= 998244353;
          if (la1 >= 998244353) la1 %= 998244353;
        }
        ans = ans * la0;
      } else {
        long long int cur;
        if (st <= 1 && en >= n - 2)
          cur = k;
        else
          cur = k - 1;
        for (int j = st + 2; j <= en; j += 2) {
          cur = cur * (k - 1);
          if (cur >= 998244353) cur %= 998244353;
        }
        ans *= cur;
      }
    }
  }
  st = -1, en = -1;
  if (ans >= 998244353) ans %= 998244353;
  for (int i = 1; i < n; i += 2) {
    if (a[i] == -1) {
      if (st == -1) {
        en = i;
        st = i;
      } else
        en += 2;
    } else {
      if (st != -1) {
        if (st == en) {
          if (st > 1 && en < n - 2) {
            if (a[st - 2] == a[en + 2])
              ans = ans * (k - 1);
            else
              ans = ans * (k - 2);
          } else if (st <= 1 && en >= n - 2)
            ans = ans * (k);
          else
            ans = ans * (k - 1);
        } else {
          long long int cur1, cur0, la1, la0;
          if (st > 1 && en < n - 2) {
            long long int v1 = a[st - 2];
            long long int v2 = a[en + 2];
            if (v1 == v2) {
              la1 = 0;
              la0 = k - 1;
            } else {
              la1 = 1;
              la0 = k - 2;
            }
            for (int j = st + 2; j <= en; j += 2) {
              cur1 = la0;
              cur0 = la1 * (k - 1) + la0 * (k - 2);
              la0 = cur0;
              la1 = cur1;
              if (la0 >= 998244353) la0 %= 998244353;
              if (la1 >= 998244353) la1 %= 998244353;
            }
            ans = ans * la0;
          } else {
            long long int cur;
            if (st <= 1 && en >= n - 2)
              cur = k;
            else
              cur = k - 1;
            for (int j = st + 2; j <= en; j += 2) {
              cur = cur * (k - 1);
              if (cur >= 998244353) cur %= 998244353;
            }
            ans *= cur;
          }
        }
      } else {
        if (i > 1 && a[i - 2] == a[i]) ans = 0;
        if (i < n - 2 && a[i + 2] == a[i]) ans = 0;
      }
      st = -1, en = -1;
    }
    if (ans >= 998244353) ans %= 998244353;
  }
  if (st != -1) {
    if (st == en) {
      if (st > 1 && en < n - 2) {
        if (a[st - 2] == a[en + 2])
          ans = ans * (k - 1);
        else
          ans = ans * (k - 2);
      } else if (st <= 1 && en >= n - 2)
        ans = ans * (k);
      else
        ans = ans * (k - 1);
    } else {
      long long int cur1, cur0, la1, la0;
      if (st > 1 && en < n - 2) {
        long long int v1 = a[st - 2];
        long long int v2 = a[en + 2];
        if (v1 == v2) {
          la1 = 0;
          la0 = k - 1;
        } else {
          la1 = 1;
          la0 = k - 2;
        }
        for (int j = st + 2; j <= en; j += 2) {
          cur1 = la0;
          cur0 = la1 * (k - 1) + la0 * (k - 2);
          la0 = cur0;
          la1 = cur1;
          if (la0 >= 998244353) la0 %= 998244353;
          if (la1 >= 998244353) la1 %= 998244353;
        }
        ans = ans * la0;
      } else {
        long long int cur;
        if (st <= 1 && en >= n - 2)
          cur = k;
        else
          cur = k - 1;
        for (int j = st + 2; j <= en; j += 2) {
          cur = cur * (k - 1);
          if (cur >= 998244353) cur %= 998244353;
        }
        ans *= cur;
      }
    }
  }
  if (ans >= 998244353) ans %= 998244353;
  st = -1, en = -1;
  long long int z = 0;
  cout << max(ans, z);
  return (0);
}
