#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define endl '\n'
using ll = long long;
template <int MOD>
struct mint {
int v;
mint(ll x = 0) : v(int(-MOD < x && x < MOD ? x : x % MOD) + (x < 0) * MOD) {}
friend mint pow(mint base, ll exp) {
mint res = 1;
while (exp) {
if (exp & 1) {
res *= base;
}
base *= base;
exp >>= 1;
}
return res;
}
mint &operator+=(mint b) {
v = v + b.v - (v + b.v >= MOD) * MOD;
return *this;
}
mint &operator-=(mint b) {
v = v - b.v + (v < b.v) * MOD;
return *this;
}
mint &operator*=(mint b) {
v = int(1ll * v * b.v % MOD);
return *this;
}
mint &operator/=(mint b) {
v = int(1ll * v * pow(b, MOD - 2).v % MOD);
return *this;
}
friend mint operator+(mint a, mint b) {
return a += b;
}
friend mint operator-(mint a, mint b) {
return a -= b;
}
friend mint operator*(mint a, mint b) {
return a *= b;
}
friend mint operator/(mint a, mint b) {
return a /= b;
}
friend ostream &operator<<(ostream &os, mint a) {
return os << a.v;
}
};
using mi = mint<998244353>;
void solve() {
int n, m; cin >> n >> m;
vi a(n); FOR(i, 0, n) cin >> a[i];
vi p(n), s(n);
int mn = m;
FOR(i, 0, n) {
if (a[i] != -1) mn = min(mn, a[i]);
p[i] = mn;
}
int mx = 1;
for (int i = n - 1; i >= 0; i--) {
if (a[i] != -1) mx = max(mx, a[i]);
s[i] = mx;
}
vi c(n);
FOR(i, 0, n) {
c[i] = a[i] == -1;
if (i) c[i] += c[i - 1];
}
mi ans = 0;
FOR(i, 0, n - 1) {
int x = c[i], y = c[n - 1] - c[i];
FOR(j, s[i + 1], p[i]) {
ans += pow(m - j, x) * pow(j, y);
}
FOR(j, s[i + 1], p[i] - 1) {
ans -= pow(m - j - 1, x) * pow(j, y);
}
}
ans += pow(m, c[n - 1]);
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; while (t--) solve();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIHZpID0gdmVjdG9yPGludD47CiNkZWZpbmUgRk9SKGksIGEsIGIpIGZvciAoaW50IGkgPSAoYSk7IGkgPCAoYik7IGkrKykKI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLCB4LmVuZCgpCiNkZWZpbmUgZW5kbCAnXG4nCgp1c2luZyBsbCA9IGxvbmcgbG9uZzsKCnRlbXBsYXRlIDxpbnQgTU9EPgpzdHJ1Y3QgbWludCB7CiAgICBpbnQgdjsKIAogICAgbWludChsbCB4ID0gMCkgOiB2KGludCgtTU9EIDwgeCAmJiB4IDwgTU9EID8geCA6IHggJSBNT0QpICsgKHggPCAwKSAqIE1PRCkge30KIAogICAgZnJpZW5kIG1pbnQgcG93KG1pbnQgYmFzZSwgbGwgZXhwKSB7CiAgICAgICAgbWludCByZXMgPSAxOwogICAgICAgIHdoaWxlIChleHApIHsKICAgICAgICAgICAgaWYgKGV4cCAmIDEpIHsKICAgICAgICAgICAgICAgIHJlcyAqPSBiYXNlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJhc2UgKj0gYmFzZTsKICAgICAgICAgICAgZXhwID4+PSAxOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmVzOwogICAgfQoKICAgIG1pbnQgJm9wZXJhdG9yKz0obWludCBiKSB7CiAgICAgICAgdiA9IHYgKyBiLnYgLSAodiArIGIudiA+PSBNT0QpICogTU9EOwogICAgICAgIHJldHVybiAqdGhpczsKICAgIH0KICAgIG1pbnQgJm9wZXJhdG9yLT0obWludCBiKSB7CiAgICAgICAgdiA9IHYgLSBiLnYgKyAodiA8IGIudikgKiBNT0Q7CiAgICAgICAgcmV0dXJuICp0aGlzOwogICAgfQogICAgbWludCAmb3BlcmF0b3IqPShtaW50IGIpIHsKICAgICAgICB2ID0gaW50KDFsbCAqIHYgKiBiLnYgJSBNT0QpOwogICAgICAgIHJldHVybiAqdGhpczsKICAgIH0KICAgIG1pbnQgJm9wZXJhdG9yLz0obWludCBiKSB7CiAgICAgICAgdiA9IGludCgxbGwgKiB2ICogcG93KGIsIE1PRCAtIDIpLnYgJSBNT0QpOwogICAgICAgIHJldHVybiAqdGhpczsKICAgIH0KICAgIGZyaWVuZCBtaW50IG9wZXJhdG9yKyhtaW50IGEsIG1pbnQgYikgewogICAgICAgIHJldHVybiBhICs9IGI7CiAgICB9CiAgICBmcmllbmQgbWludCBvcGVyYXRvci0obWludCBhLCBtaW50IGIpIHsKICAgICAgICByZXR1cm4gYSAtPSBiOwogICAgfQogICAgZnJpZW5kIG1pbnQgb3BlcmF0b3IqKG1pbnQgYSwgbWludCBiKSB7CiAgICAgICAgcmV0dXJuIGEgKj0gYjsKICAgIH0KICAgIGZyaWVuZCBtaW50IG9wZXJhdG9yLyhtaW50IGEsIG1pbnQgYikgewogICAgICAgIHJldHVybiBhIC89IGI7CiAgICB9CiAgICBmcmllbmQgb3N0cmVhbSAmb3BlcmF0b3I8PChvc3RyZWFtICZvcywgbWludCBhKSB7CiAgICAgICAgcmV0dXJuIG9zIDw8IGEudjsKICAgIH0KfTsKCnVzaW5nIG1pID0gbWludDw5OTgyNDQzNTM+OwoKdm9pZCBzb2x2ZSgpIHsKCWludCBuLCBtOyBjaW4gPj4gbiA+PiBtOwoJdmkgYShuKTsgRk9SKGksIDAsIG4pIGNpbiA+PiBhW2ldOwoJdmkgcChuKSwgcyhuKTsKCWludCBtbiA9IG07CglGT1IoaSwgMCwgbikgewoJCWlmIChhW2ldICE9IC0xKSBtbiA9IG1pbihtbiwgYVtpXSk7CgkJcFtpXSA9IG1uOwoJfQoJaW50IG14ID0gMTsKCWZvciAoaW50IGkgPSBuIC0gMTsgaSA+PSAwOyBpLS0pIHsKCQlpZiAoYVtpXSAhPSAtMSkgbXggPSBtYXgobXgsIGFbaV0pOwoJCXNbaV0gPSBteDsKCX0KCXZpIGMobik7CglGT1IoaSwgMCwgbikgewoJCWNbaV0gPS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