#include <bits/stdc++.h>
using namespace std;
long long mod= 998244353;

long long numOfWays(long long a, long long b, long long k, long long l){
	long long dp[l+1][2];
	dp[0][1] = 1;
	if(a==-1){
		dp[0][1] = 0;
	}
	dp[0][0] = 0;
	long long sum=1;
	for(int i=1;i<=l;i++){
		dp[i][0] = sum - dp[i-1][0];
		dp[i][1] = sum - dp[i-1][1];
		sum = (((dp[i][0]%mod)*((k-1)%mod))%mod + dp[i][1]%mod)%mod;
	}
	if(b>0 && b<=k)
		sum = sum - dp[l][0];
	return sum%mod;
}

int main(){
	long long int n, k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-2;i++)
		if(a[i]==a[i+2]){
			cout<<0<<endl;
			return 0;
		}
	long long start=-1, end=-1, l=0, ways=1;
	for(int i=0;i<n;i+=2){
		//cout<<"odd: "<<a[i]<<endl;
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				//cout<<"check= "<<ways<<endl;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		else if(a[i]==-1){
			l++;
		}
	}
	//cout<<"odd end l= "<<l<<" start= "<<start<<" end= "<<end<<endl;
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	start = -1, end = -1, l=0;
	for(int i=1;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	// long long w = numOfWays(3, -1, 3, 1);
	// cout<<w<<endl;
	cout<<ways<<endl;
	return 0;
}

// 7 6
// =<==<<
// >>>><=
// >>>>=>
// >>>><=
// >=>><<
// >>>>>>
// >>>>=>


#include <bits/stdc++.h>
using namespace std;
long long mod= 998244353;

long long numOfWays(long long a, long long b, long long k, long long l){
	long long dp[l+1][2];
	dp[0][1] = 1;
	if(a==-1 || a>k){
		dp[0][1] = 0;
	}
	dp[0][0] = 0;
	long long sum=1;
	for(int i=1;i<=l;i++){
		dp[i][0] = (mod + sum - dp[i-1][0])%mod;
		dp[i][1] = (mod + sum - dp[i-1][1])%mod;
		sum = (((dp[i][0]%mod)*((k-1)%mod))%mod + dp[i][1]%mod)%mod;
	}
	if(b>0 && b<=k)
		sum = (mod + sum - dp[l][0])%mod;
	return sum;
}

int main(){
	long long int n, k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-2;i++)
		if(a[i]!=-1 && a[i]==a[i+2]){
			cout<<0<<endl;
			return 0;
		}
	long long start=-1, end=-1, l=0, ways=1;
	for(int i=0;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		else if(a[i]==-1){
			l++;
		}
	}
	//cout<<"odd end l= "<<l<<" start= "<<start<<" end= "<<end<<endl;
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	start = -1, end = -1, l=0;
	for(int i=1;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	// long long w = numOfWays(3, -1, 3, 1);
	// cout<<w<<endl;
	cout<<ways<<endl;
	return 0;
}

// 7 6
// =<==<<
// >>>><=
// >>>>=>
// >>>><=
// >=>><<
// >>>>>>
// >>>>=>


#include <bits/stdc++.h>
using namespace std;
long long mod= 998244353;

long long numOfWays(long long a, long long b, long long k, long long l){
	long long dp[l+1][2];
	dp[0][1] = 1;
	if(a==-1){
		dp[0][1] = 0;
	}
	dp[0][0] = 0;
	long long sum=1;
	for(int i=1;i<=l;i++){
		dp[i][0] = sum - dp[i-1][0];
		dp[i][1] = sum - dp[i-1][1];
		sum = (((dp[i][0]%mod)*((k-1)%mod))%mod + dp[i][1]%mod)%mod;
	}
	if(b>0 && b<=k)
		sum = sum - dp[l][0];
	return sum%mod;
}

int main(){
	long long int n, k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-2;i++)
		if(a[i]!=-1 && a[i]==a[i+2]){
			cout<<0<<endl;
			return 0;
		}
	long long start=-1, end=-1, l=0, ways=1;
	for(int i=0;i<n;i+=2){
		//cout<<"odd: "<<a[i]<<endl;
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				//cout<<"check= "<<ways<<endl;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		else if(a[i]==-1){
			l++;
		}
	}
	//cout<<"odd end l= "<<l<<" start= "<<start<<" end= "<<end<<endl;
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	start = -1, end = -1, l=0;
	for(int i=1;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	// long long w = numOfWays(3, -1, 3, 1);
	// cout<<w<<endl;
	cout<<ways<<endl;
	return 0;
}

// 7 6
// =<==<<
// >>>><=
// >>>>=>
// >>>><=
// >=>><<
// >>>>>>
// >>>>=>


#include <bits/stdc++.h>
using namespace std;
long long mod= 998244353;

long long numOfWays(long long a, long long b, long long k, long long l){
	long long dp[l+1][2];
	dp[0][1] = 1;
	if(a==-1){
		dp[0][1] = 0;
	}
	dp[0][0] = 0;
	long long sum=1;
	for(int i=1;i<=l;i++){
		dp[i][0] = (mod + sum - dp[i-1][0])%mod;
		dp[i][1] = (mod + sum - dp[i-1][1])%mod;
		sum = (((dp[i][0]%mod)*((k-1)%mod))%mod + dp[i][1]%mod)%mod;
	}
	if(a==b && a>0)
		sum = (mod + sum - dp[l][1])%mod;
	else if(b>0 && b<=k)
		sum = (mod + sum - dp[l][0])%mod;
	return sum;
}

int main(){
	long long int n, k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-2;i++)
		if(a[i]!=-1 && a[i]==a[i+2]){
			cout<<0<<endl;
			return 0;
		}
	long long start=-1, end=-1, l=0, ways=1;
	for(int i=0;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		else if(a[i]==-1){
			l++;
		}
	}
	//cout<<"odd end l= "<<l<<" start= "<<start<<" end= "<<end<<endl;
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	start = -1, end = -1, l=0;
	for(int i=1;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	// long long w = numOfWays(3, -1, 3, 1);
	// cout<<w<<endl;
	cout<<ways<<endl;
	return 0;
}

// 7 6
// =<==<<
// >>>><=
// >>>>=>
// >>>><=
// >=>><<
// >>>>>>
// >>>>=>


#include <bits/stdc++.h>
using namespace std;
long long mod= 998244353;

long long numOfWays(long long a, long long b, long long k, long long l){
	long long dp[l+1][2];
	dp[0][1] = 1;
	if(a==-1){
		dp[0][1] = 0;
	}
	dp[0][0] = 0;
	long long sum=1;
	for(int i=1;i<=l;i++){
		dp[i][0] = sum - dp[i-1][0];
		dp[i][1] = sum - dp[i-1][1];
		sum = (((dp[i][0]%mod)*((k-1)%mod))%mod + dp[i][1]%mod)%mod;
	}
	if(b>0 && b<=k)
		sum = sum - dp[l][0];
	return sum%mod;
}

int main(){
	long long int n, k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long start=-1, end=-1, l=0, ways=1;
	for(int i=0;i<n;i+=2){
		//cout<<"odd: "<<a[i]<<endl;
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				//cout<<"check= "<<ways<<endl;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		else if(a[i]==-1){
			l++;
		}
	}
	//cout<<"odd end l= "<<l<<" start= "<<start<<" end= "<<end<<endl;
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	start = -1, end = -1, l=0;
	for(int i=1;i<n;i+=2){
		if(a[i]>0){
			if(l==0)
				start = a[i];
			else{
				end = a[i];
				ways = (ways*numOfWays(start, end, k, l))%mod;
				start = a[i];
				end = -1;
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	// long long w = numOfWays(3, -1, 3, 1);
	// cout<<w<<endl;
	cout<<ways<<endl;
	return 0;
}

// 7 6
// =<==<<
// >>>><=
// >>>>=>
// >>>><=
// >=>><<
// >>>>>>
// >>>>=>


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 998244353;
LL dp[200005][2];
int n, k, a;
LL solve(vector<int> &a){
    memset(dp, 0, sizeof(dp));
    int last = 0;
    for(int i=1;i<a.size();i++){
        int val = a[i];
        if(i == 1){
            if(val == -1){
                last = 1;
                dp[i][0] = 1;
                dp[i][1] = 1;
            }
            else{
                last = val;
                dp[i][0] = 1;
            }
        }
        else{
            if(val == -1){
                dp[i][0] = (dp[i][0] + dp[i-1][1]*(k-1))%mod;
                dp[i][1] = (dp[i][1] + dp[i-1][0] + dp[i-1][1]*(k-2))%mod;
            }
            else{
                if(last == val){
                    dp[i][0] = (dp[i][0] + dp[i-1][1]*(k-1))%mod;
                }
                else{
                    dp[i][0] = (dp[i][0] + dp[i-1][0] + dp[i-1][1]*(k-2))%mod;
                }
            }
        }
    }
    return (dp[a.size()-1][0] + dp[a.size()-1][1]*(k-1))%mod;
}
int main(){
    scanf("%d%d", &n, &k);
    vector<int> odd, even;
    odd.push_back(0);
    even.push_back(0);
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        if(i%2 == 1) odd.push_back(a);
        else even.push_back(a);
    }
    LL ans = solve(odd)*solve(even)%mod;
    printf("%lld\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 998244353;
LL dp[200005][2];
int n, k, a;
LL solve(vector<int> &a){
    memset(dp, 0, sizeof(dp));
    int last = 0;
    for(int i=1;i<a.size();i++){
        int val = a[i];
        if(i == 1){
            if(val == -1){
                last = 1;
                dp[i][0] = 1;
                dp[i][1] = 1;
            }
            else{
                last = val;
                dp[i][0] = 1;
            }
        }
        else{
            if(val == -1){
                dp[i][0] = (dp[i][0] + dp[i-1][1]*(k-1))%mod;
                dp[i][1] = (dp[i][1] + dp[i-1][0] + dp[i-1][1]*(k-2))%mod;
            }
            else{
                if(last == val){
                    dp[i][0] = (dp[i][0] + dp[i-1][1]*(k-1))%mod;
                }
                else{
                    dp[i][0] = (dp[i][0] + dp[i-1][0] + dp[i-1][1]*(k-2))%mod;
                }
                last = val;
            }
        }
    }
    return (dp[a.size()-1][0] + dp[a.size()-1][1]*(k-1))%mod;
}
int main(){
    scanf("%d%d", &n, &k);
    vector<int> odd, even;
    odd.push_back(0);
    even.push_back(0);
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        if(i%2 == 1) odd.push_back(a);
        else even.push_back(a);
    }
    LL ans = solve(odd)*solve(even)%mod;
    printf("%lld\n", ans);
}


/*
  AUTHOR:SOURABH
  CREATED:22:03:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

///------------------------------------------------>MODEX<-------------------------------------------------------------///
ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}
///*********************************************************************************************************************///

/*
///-------------------------------------------->SEGMENTED TREE<---------------------------------------------------------///
void build(ll node,ll s,ll e)
{
    if(s==e)
    {
        tree[node]=a[s];
    }
    else
    {
        ll mid=(s+e)/2;
        build(2*node,s,mid);
        build(2*node+1,mid+1,e);

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
void update(ll node,ll s,ll e,ll idx,ll val)
{
    if(s==e)
    {
        a[idx]=val;
        tree[node]=val;
    }
    else
    {
        ll mid=(s+e)/2;
        if(s<=idx && idx<=mid)
        {
            update(2*node,s,mid,idx,val);
        }
        else
        {
            update(2*node+1,mid+1,e,idx,val);
        }

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
ll query(ll node,ll s,ll e,ll l,ll r)
{
    if(r<s || e<l)
    {
        return 0;
    }
    if(l<=s && e<=r)
    {
        return tree[node];
    }
    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
void rangeupdate(ll node,ll s,ll e,ll l,ll r,ll val)
{
    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(s>e || s>r || e<l)
        return;

    if(l<=s && e<=r)
    {
        tree[node]+=val;
        if(s!=e)
        {
            lazy[2*node]+=val;
            lazy[2*node+1]+=val;
        }
        return;
    }

    ll mid=(s+e)/2;
    rangeupdate(2*node,s,mid,l,r,val);
    rangeupdate(2*node+1,mid+1,e,l,r,val);

    tree[node]=min(tree[2*node],tree[2*node+1]);
}
ll rangequery(ll node,ll s,ll e,ll l,ll r)
{
    if(s>e || s>r || e<l)
        return 1000000000;

    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(l<=s && e<=r)
        return tree[node];

    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
///***********************************************************************************************************************///

/*
///---------------------------------------------->DSU<--------------------------------------------------------------------///
void initalize(ll n)
{
    ll i;
    fs(i,1,n+1)
    {a[i]=i;si[i]=1;}
}
ll root(ll i)
{
    W(a[i]!=i)
    {
        a[i]=a[a[i]];
        i=a[i];
    }
    return i;
}
bool find(ll x,ll y)
{
    if(root(x)==root(y))
        return true;
    else
        return false;
}
void U(ll x,ll y)
{
    ll root_x=root(x);
    ll root_y=root(y);
    if(si[root_x]>si[root_y])
    {
        a[root_y]=a[root_x];
        si[root_x]+=si[root_y];
        si[root_y]=0;
    }
    else
    {
        a[root_x]=a[root_y];
        si[root_y]+=si[root_x];
        si[root_x]=0;
    }
}
///************************************************************************************************************************///

/*
///---------------------------------------------->MST(KRUSKAL)<------------------------------------------------------------///
ll kruskal(ll m)
{
    ll x,y,i;
    ll cost,mincost=0;
    fs(i,1,m+1)
    {
        x=p[i].se.fi;
        y=p[i].se.se;
        cost=p[i].fi;

        if(!find(x,y))
        {
            mincost+=cost;
            U(x,y);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///------------------------------------------------>MST(PRIM)<------------------------------------------------------------///
ll prim(ll x)
{
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll y,mincost=0;
    pll P;
    Q.push(mp(0, x));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(mark[x]==true)
            continue;

        mincost+=P.fi;
        mark[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            y=adj[x][i].se;
            if(!mark[y])
                Q.push(adj[x][i]);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///----------------------------------------------->DFS<-------------------------------------------------------------------///
ll dfs(ll root)
{
    ll i,j,k,sum=1;
    vis[root]=true;
    k=adj[root].size();
    fn(i,k)
    {
        j=adj[root][i];
        if(!vis[j])
        {
            sum+=dfs(j);
        }
    }
    return sum;
}
///***********************************************************************************************************************///

/*
///-------------------------------------------->BFS<----------------------------------------------------------------------///
void bfs(ll root)
{
    ll i,j,k,start;
    set<ll> q;
    q.insert(root);
    vis[root]=true;
    W(!q.empty())
    {
        it=q.begin();
        start=*it;
        ans.pb(start);
        q.erase(it);
        //k=adj[start].size();
        fit(it,adj[start])
        {
            j=*it;
            if(!vis[j])
            {
                vis[j]=true;
                q.insert(j);
            }
        }
    }
}
///************************************************************************************************************************///

/*
///--------------------------------------------->DIJKSTRA<-----------------------------------------------------------------///
void dijkstra(ll src)
{
    memset(vis,true,sizeof(vis));
    dis[src]=0;
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll x,y,i,k,wt;
    pll P;
    Q.push(mp(0,src));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(vis[x])
            continue;

        vis[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            wt=adj[x][i].se;
            y=adj[x][i].fi;
            if(dis[x]+wt<dis[y])
            {
                dis[y]=dis[x]+wt;
                Q.push(mp(dis[y],y));
            }
        }
    }
}
///***********************************************************************************************************************///

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,k,i,ans1,ans2,c,f,p;
    cin>>n>>k;
    vll a(n);
    fn(i,n)
    cin>>a[i];
    ll dp1[n/2],dp2[n/2];
    dp1[0]=0;
    dp2[0]=1;
    fs(i,1,n/2)
    {
        dp1[i]=((k-1)*dp2[i-1])%mod;
        dp2[i]=(dp1[i-1]+((k-2)*dp2[i-1])%mod)%mod;
    }
    ans1=1;
    c=0;
    f=0;
    for(i=0;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans1=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans1=(ans1*dp1[c])%mod;
                else if(c>0)
                    ans1=(ans1*dp2[c])%mod;
                else if(c==0)
                {
                    if(a[i]==a[i-2])
                        {ans1=0;goto e;}
                }
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans1=(ans1*modex(k-1,c))%mod;
        else
        ans1=(ans1*(modex(k-1,c-1)*k)%mod)%mod;
    }
    e:
    ans2=1;
    c=0;
    f=0;
    for(i=1;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans2=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans2=(ans2*dp1[c])%mod;
                else if(c>0)
                    ans2=(ans2*dp2[c])%mod;
                else if(c==0)
                {
                    if(a[i]==a[i-2])
                    {ans2=0;goto g;}
                }
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans2=(ans2*modex(k-1,c))%mod;
        else
        ans2=(ans2*(modex(k-1,c-1)*k)%mod)%mod;
    }
    g:
    cout<<(ans1*ans2)%mod;
    return 0;
}


/*
  AUTHOR:SOURABH
  CREATED:22:03:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

///------------------------------------------------>MODEX<-------------------------------------------------------------///
ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}
///*********************************************************************************************************************///

/*
///-------------------------------------------->SEGMENTED TREE<---------------------------------------------------------///
void build(ll node,ll s,ll e)
{
    if(s==e)
    {
        tree[node]=a[s];
    }
    else
    {
        ll mid=(s+e)/2;
        build(2*node,s,mid);
        build(2*node+1,mid+1,e);

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
void update(ll node,ll s,ll e,ll idx,ll val)
{
    if(s==e)
    {
        a[idx]=val;
        tree[node]=val;
    }
    else
    {
        ll mid=(s+e)/2;
        if(s<=idx && idx<=mid)
        {
            update(2*node,s,mid,idx,val);
        }
        else
        {
            update(2*node+1,mid+1,e,idx,val);
        }

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
ll query(ll node,ll s,ll e,ll l,ll r)
{
    if(r<s || e<l)
    {
        return 0;
    }
    if(l<=s && e<=r)
    {
        return tree[node];
    }
    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
void rangeupdate(ll node,ll s,ll e,ll l,ll r,ll val)
{
    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(s>e || s>r || e<l)
        return;

    if(l<=s && e<=r)
    {
        tree[node]+=val;
        if(s!=e)
        {
            lazy[2*node]+=val;
            lazy[2*node+1]+=val;
        }
        return;
    }

    ll mid=(s+e)/2;
    rangeupdate(2*node,s,mid,l,r,val);
    rangeupdate(2*node+1,mid+1,e,l,r,val);

    tree[node]=min(tree[2*node],tree[2*node+1]);
}
ll rangequery(ll node,ll s,ll e,ll l,ll r)
{
    if(s>e || s>r || e<l)
        return 1000000000;

    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(l<=s && e<=r)
        return tree[node];

    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
///***********************************************************************************************************************///

/*
///---------------------------------------------->DSU<--------------------------------------------------------------------///
void initalize(ll n)
{
    ll i;
    fs(i,1,n+1)
    {a[i]=i;si[i]=1;}
}
ll root(ll i)
{
    W(a[i]!=i)
    {
        a[i]=a[a[i]];
        i=a[i];
    }
    return i;
}
bool find(ll x,ll y)
{
    if(root(x)==root(y))
        return true;
    else
        return false;
}
void U(ll x,ll y)
{
    ll root_x=root(x);
    ll root_y=root(y);
    if(si[root_x]>si[root_y])
    {
        a[root_y]=a[root_x];
        si[root_x]+=si[root_y];
        si[root_y]=0;
    }
    else
    {
        a[root_x]=a[root_y];
        si[root_y]+=si[root_x];
        si[root_x]=0;
    }
}
///************************************************************************************************************************///

/*
///---------------------------------------------->MST(KRUSKAL)<------------------------------------------------------------///
ll kruskal(ll m)
{
    ll x,y,i;
    ll cost,mincost=0;
    fs(i,1,m+1)
    {
        x=p[i].se.fi;
        y=p[i].se.se;
        cost=p[i].fi;

        if(!find(x,y))
        {
            mincost+=cost;
            U(x,y);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///------------------------------------------------>MST(PRIM)<------------------------------------------------------------///
ll prim(ll x)
{
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll y,mincost=0;
    pll P;
    Q.push(mp(0, x));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(mark[x]==true)
            continue;

        mincost+=P.fi;
        mark[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            y=adj[x][i].se;
            if(!mark[y])
                Q.push(adj[x][i]);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///----------------------------------------------->DFS<-------------------------------------------------------------------///
ll dfs(ll root)
{
    ll i,j,k,sum=1;
    vis[root]=true;
    k=adj[root].size();
    fn(i,k)
    {
        j=adj[root][i];
        if(!vis[j])
        {
            sum+=dfs(j);
        }
    }
    return sum;
}
///***********************************************************************************************************************///

/*
///-------------------------------------------->BFS<----------------------------------------------------------------------///
void bfs(ll root)
{
    ll i,j,k,start;
    set<ll> q;
    q.insert(root);
    vis[root]=true;
    W(!q.empty())
    {
        it=q.begin();
        start=*it;
        ans.pb(start);
        q.erase(it);
        //k=adj[start].size();
        fit(it,adj[start])
        {
            j=*it;
            if(!vis[j])
            {
                vis[j]=true;
                q.insert(j);
            }
        }
    }
}
///************************************************************************************************************************///

/*
///--------------------------------------------->DIJKSTRA<-----------------------------------------------------------------///
void dijkstra(ll src)
{
    memset(vis,true,sizeof(vis));
    dis[src]=0;
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll x,y,i,k,wt;
    pll P;
    Q.push(mp(0,src));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(vis[x])
            continue;

        vis[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            wt=adj[x][i].se;
            y=adj[x][i].fi;
            if(dis[x]+wt<dis[y])
            {
                dis[y]=dis[x]+wt;
                Q.push(mp(dis[y],y));
            }
        }
    }
}
///***********************************************************************************************************************///

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,k,i,ans1,ans2,c,f,p;
    cin>>n>>k;
    vll a(n);
    fn(i,n)
    cin>>a[i];
    ll dp1[n/2],dp2[n/2];
    dp1[0]=0;dp1[1]=k-1;dp1[2]=(k-1)*(k-2);
    dp2[0]=0;dp2[1]=k-2;dp2[2]=(k-1)*(k-2)+1;
    fs(i,3,n/2)
    {
        dp1[i]=(dp1[i-1]+((k-1)*dp1[i-2])%mod)%mod;
        dp2[i]=(dp2[i-1]+((k-1)*dp1[i-2])%mod)%mod;
    }
    ans1=1;
    c=0;
    f=0;
    for(i=0;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans1=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans1=(ans1*dp1[c])%mod;
                else if(c>0)
                    ans1=(ans1*dp2[c])%mod;
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans1=(ans1*modex(k-1,c))%mod;
        else
        ans1=(ans1*(modex(k-1,c-1)*k)%mod)%mod;
    }
    ans2=1;
    c=0;
    f=0;
    for(i=1;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans2=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans2=(ans2*dp1[c])%mod;
                else if(c>0)
                    ans2=(ans2*dp2[c])%mod;
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans2=(ans2*modex(k-1,c))%mod;
        else
        ans2=(ans2*(modex(k-1,c-1)*k)%mod)%mod;
    }
    cout<<(ans1*ans2)%mod;
    return 0;
}


/*
  AUTHOR:SOURABH
  CREATED:22:03:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

///------------------------------------------------>MODEX<-------------------------------------------------------------///
ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}
///*********************************************************************************************************************///

/*
///-------------------------------------------->SEGMENTED TREE<---------------------------------------------------------///
void build(ll node,ll s,ll e)
{
    if(s==e)
    {
        tree[node]=a[s];
    }
    else
    {
        ll mid=(s+e)/2;
        build(2*node,s,mid);
        build(2*node+1,mid+1,e);

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
void update(ll node,ll s,ll e,ll idx,ll val)
{
    if(s==e)
    {
        a[idx]=val;
        tree[node]=val;
    }
    else
    {
        ll mid=(s+e)/2;
        if(s<=idx && idx<=mid)
        {
            update(2*node,s,mid,idx,val);
        }
        else
        {
            update(2*node+1,mid+1,e,idx,val);
        }

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
ll query(ll node,ll s,ll e,ll l,ll r)
{
    if(r<s || e<l)
    {
        return 0;
    }
    if(l<=s && e<=r)
    {
        return tree[node];
    }
    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
void rangeupdate(ll node,ll s,ll e,ll l,ll r,ll val)
{
    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(s>e || s>r || e<l)
        return;

    if(l<=s && e<=r)
    {
        tree[node]+=val;
        if(s!=e)
        {
            lazy[2*node]+=val;
            lazy[2*node+1]+=val;
        }
        return;
    }

    ll mid=(s+e)/2;
    rangeupdate(2*node,s,mid,l,r,val);
    rangeupdate(2*node+1,mid+1,e,l,r,val);

    tree[node]=min(tree[2*node],tree[2*node+1]);
}
ll rangequery(ll node,ll s,ll e,ll l,ll r)
{
    if(s>e || s>r || e<l)
        return 1000000000;

    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(l<=s && e<=r)
        return tree[node];

    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
///***********************************************************************************************************************///

/*
///---------------------------------------------->DSU<--------------------------------------------------------------------///
void initalize(ll n)
{
    ll i;
    fs(i,1,n+1)
    {a[i]=i;si[i]=1;}
}
ll root(ll i)
{
    W(a[i]!=i)
    {
        a[i]=a[a[i]];
        i=a[i];
    }
    return i;
}
bool find(ll x,ll y)
{
    if(root(x)==root(y))
        return true;
    else
        return false;
}
void U(ll x,ll y)
{
    ll root_x=root(x);
    ll root_y=root(y);
    if(si[root_x]>si[root_y])
    {
        a[root_y]=a[root_x];
        si[root_x]+=si[root_y];
        si[root_y]=0;
    }
    else
    {
        a[root_x]=a[root_y];
        si[root_y]+=si[root_x];
        si[root_x]=0;
    }
}
///************************************************************************************************************************///

/*
///---------------------------------------------->MST(KRUSKAL)<------------------------------------------------------------///
ll kruskal(ll m)
{
    ll x,y,i;
    ll cost,mincost=0;
    fs(i,1,m+1)
    {
        x=p[i].se.fi;
        y=p[i].se.se;
        cost=p[i].fi;

        if(!find(x,y))
        {
            mincost+=cost;
            U(x,y);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///------------------------------------------------>MST(PRIM)<------------------------------------------------------------///
ll prim(ll x)
{
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll y,mincost=0;
    pll P;
    Q.push(mp(0, x));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(mark[x]==true)
            continue;

        mincost+=P.fi;
        mark[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            y=adj[x][i].se;
            if(!mark[y])
                Q.push(adj[x][i]);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///----------------------------------------------->DFS<-------------------------------------------------------------------///
ll dfs(ll root)
{
    ll i,j,k,sum=1;
    vis[root]=true;
    k=adj[root].size();
    fn(i,k)
    {
        j=adj[root][i];
        if(!vis[j])
        {
            sum+=dfs(j);
        }
    }
    return sum;
}
///***********************************************************************************************************************///

/*
///-------------------------------------------->BFS<----------------------------------------------------------------------///
void bfs(ll root)
{
    ll i,j,k,start;
    set<ll> q;
    q.insert(root);
    vis[root]=true;
    W(!q.empty())
    {
        it=q.begin();
        start=*it;
        ans.pb(start);
        q.erase(it);
        //k=adj[start].size();
        fit(it,adj[start])
        {
            j=*it;
            if(!vis[j])
            {
                vis[j]=true;
                q.insert(j);
            }
        }
    }
}
///************************************************************************************************************************///

/*
///--------------------------------------------->DIJKSTRA<-----------------------------------------------------------------///
void dijkstra(ll src)
{
    memset(vis,true,sizeof(vis));
    dis[src]=0;
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll x,y,i,k,wt;
    pll P;
    Q.push(mp(0,src));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(vis[x])
            continue;

        vis[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            wt=adj[x][i].se;
            y=adj[x][i].fi;
            if(dis[x]+wt<dis[y])
            {
                dis[y]=dis[x]+wt;
                Q.push(mp(dis[y],y));
            }
        }
    }
}
///***********************************************************************************************************************///

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,k,i,ans1,ans2,c,f,p;
    cin>>n>>k;
    vll a(n);
    fn(i,n)
    cin>>a[i];
    ll dp1[n/2],dp2[n/2];
    dp1[0]=0;dp1[1]=k-1;dp1[2]=(k-1)*(k-2);
    dp2[0]=0;dp2[1]=k-2;dp2[2]=(k-1)*(k-2)+1;
    fs(i,3,n/2)
    {
        dp1[i]=(dp1[i-1]+((k-1)*dp1[i-2])%mod)%mod;
        dp2[i]=(dp2[i-1]+((k-1)*dp1[i-2])%mod)%mod;
    }
    ans1=1;
    c=0;
    f=0;
    for(i=0;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans1=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans1=(ans1*dp1[c])%mod;
                else if(c>0)
                    ans1=(ans1*dp2[c])%mod;
                else if(c==0)
                {
                    if(a[i]==a[i-2])
                        {ans1=0;goto e;}
                }
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans1=(ans1*modex(k-1,c))%mod;
        else
        ans1=(ans1*(modex(k-1,c-1)*k)%mod)%mod;
    }
    e:
    ans2=1;
    c=0;
    f=0;
    for(i=1;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans2=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans2=(ans2*dp1[c])%mod;
                else if(c>0)
                    ans2=(ans2*dp2[c])%mod;
                else if(c==0)
                {
                    if(a[i]==a[i-2])
                    {ans2=0;goto g;}
                }
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans2=(ans2*modex(k-1,c))%mod;
        else
        ans2=(ans2*(modex(k-1,c-1)*k)%mod)%mod;
    }
    g:
    cout<<(ans1*ans2)%mod;
    return 0;
}


/*
  AUTHOR:SOURABH
  CREATED:22:03:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

///------------------------------------------------>MODEX<-------------------------------------------------------------///
ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}
///*********************************************************************************************************************///

/*
///-------------------------------------------->SEGMENTED TREE<---------------------------------------------------------///
void build(ll node,ll s,ll e)
{
    if(s==e)
    {
        tree[node]=a[s];
    }
    else
    {
        ll mid=(s+e)/2;
        build(2*node,s,mid);
        build(2*node+1,mid+1,e);

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
void update(ll node,ll s,ll e,ll idx,ll val)
{
    if(s==e)
    {
        a[idx]=val;
        tree[node]=val;
    }
    else
    {
        ll mid=(s+e)/2;
        if(s<=idx && idx<=mid)
        {
            update(2*node,s,mid,idx,val);
        }
        else
        {
            update(2*node+1,mid+1,e,idx,val);
        }

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
ll query(ll node,ll s,ll e,ll l,ll r)
{
    if(r<s || e<l)
    {
        return 0;
    }
    if(l<=s && e<=r)
    {
        return tree[node];
    }
    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
void rangeupdate(ll node,ll s,ll e,ll l,ll r,ll val)
{
    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(s>e || s>r || e<l)
        return;

    if(l<=s && e<=r)
    {
        tree[node]+=val;
        if(s!=e)
        {
            lazy[2*node]+=val;
            lazy[2*node+1]+=val;
        }
        return;
    }

    ll mid=(s+e)/2;
    rangeupdate(2*node,s,mid,l,r,val);
    rangeupdate(2*node+1,mid+1,e,l,r,val);

    tree[node]=min(tree[2*node],tree[2*node+1]);
}
ll rangequery(ll node,ll s,ll e,ll l,ll r)
{
    if(s>e || s>r || e<l)
        return 1000000000;

    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(l<=s && e<=r)
        return tree[node];

    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
///***********************************************************************************************************************///

/*
///---------------------------------------------->DSU<--------------------------------------------------------------------///
void initalize(ll n)
{
    ll i;
    fs(i,1,n+1)
    {a[i]=i;si[i]=1;}
}
ll root(ll i)
{
    W(a[i]!=i)
    {
        a[i]=a[a[i]];
        i=a[i];
    }
    return i;
}
bool find(ll x,ll y)
{
    if(root(x)==root(y))
        return true;
    else
        return false;
}
void U(ll x,ll y)
{
    ll root_x=root(x);
    ll root_y=root(y);
    if(si[root_x]>si[root_y])
    {
        a[root_y]=a[root_x];
        si[root_x]+=si[root_y];
        si[root_y]=0;
    }
    else
    {
        a[root_x]=a[root_y];
        si[root_y]+=si[root_x];
        si[root_x]=0;
    }
}
///************************************************************************************************************************///

/*
///---------------------------------------------->MST(KRUSKAL)<------------------------------------------------------------///
ll kruskal(ll m)
{
    ll x,y,i;
    ll cost,mincost=0;
    fs(i,1,m+1)
    {
        x=p[i].se.fi;
        y=p[i].se.se;
        cost=p[i].fi;

        if(!find(x,y))
        {
            mincost+=cost;
            U(x,y);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///------------------------------------------------>MST(PRIM)<------------------------------------------------------------///
ll prim(ll x)
{
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll y,mincost=0;
    pll P;
    Q.push(mp(0, x));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(mark[x]==true)
            continue;

        mincost+=P.fi;
        mark[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            y=adj[x][i].se;
            if(!mark[y])
                Q.push(adj[x][i]);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///----------------------------------------------->DFS<-------------------------------------------------------------------///
ll dfs(ll root)
{
    ll i,j,k,sum=1;
    vis[root]=true;
    k=adj[root].size();
    fn(i,k)
    {
        j=adj[root][i];
        if(!vis[j])
        {
            sum+=dfs(j);
        }
    }
    return sum;
}
///***********************************************************************************************************************///

/*
///-------------------------------------------->BFS<----------------------------------------------------------------------///
void bfs(ll root)
{
    ll i,j,k,start;
    set<ll> q;
    q.insert(root);
    vis[root]=true;
    W(!q.empty())
    {
        it=q.begin();
        start=*it;
        ans.pb(start);
        q.erase(it);
        //k=adj[start].size();
        fit(it,adj[start])
        {
            j=*it;
            if(!vis[j])
            {
                vis[j]=true;
                q.insert(j);
            }
        }
    }
}
///************************************************************************************************************************///

/*
///--------------------------------------------->DIJKSTRA<-----------------------------------------------------------------///
void dijkstra(ll src)
{
    memset(vis,true,sizeof(vis));
    dis[src]=0;
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll x,y,i,k,wt;
    pll P;
    Q.push(mp(0,src));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(vis[x])
            continue;

        vis[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            wt=adj[x][i].se;
            y=adj[x][i].fi;
            if(dis[x]+wt<dis[y])
            {
                dis[y]=dis[x]+wt;
                Q.push(mp(dis[y],y));
            }
        }
    }
}
///***********************************************************************************************************************///

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,k,ans=1,k1,i,j,sum,f,r,c;
    cin>>n>>k;
    vll a(n),v;
    ll fact[k+1];
    fact[0]=1;
    fs(i,1,k+1)
    fact[i]=(fact[i-1]*i)%mod;
    fn(i,n)
    {
        cin>>a[i];
        if(a[i]==-1)
        v.pb(i);
    }
    k1=v.size();
    fn(j,k1)
    {
        sum=0;f=0;
        if(v[j]-2>=0)
        {sum+=k-1;f=1;}
        r=v[j]+2;
        c=1;
        W(r<n && a[r]==-1)
        {
            c++;
            r+=2;
        }
        if(r<n)
        {
            if(f)
            {
                if(a[v[j]-2]!=a[r])
                sum--;
            }
            else
                sum=k-1;
            f=1;
        }
        if(f==0)
            sum=k;
        ll p=(fact[sum]*modex(fact[sum-c],mod-2))%mod;
        ans=(ans*p)%mod;
        j+=c-1;
    }
    cout<<ans;
    return 0;
}


/*
  AUTHOR:SOURABH
  CREATED:22:03:19
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pair<int, int> , null_type, less< pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

///------------------------------------------------>MODEX<-------------------------------------------------------------///
ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}
///*********************************************************************************************************************///

/*
///-------------------------------------------->SEGMENTED TREE<---------------------------------------------------------///
void build(ll node,ll s,ll e)
{
    if(s==e)
    {
        tree[node]=a[s];
    }
    else
    {
        ll mid=(s+e)/2;
        build(2*node,s,mid);
        build(2*node+1,mid+1,e);

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
void update(ll node,ll s,ll e,ll idx,ll val)
{
    if(s==e)
    {
        a[idx]=val;
        tree[node]=val;
    }
    else
    {
        ll mid=(s+e)/2;
        if(s<=idx && idx<=mid)
        {
            update(2*node,s,mid,idx,val);
        }
        else
        {
            update(2*node+1,mid+1,e,idx,val);
        }

        tree[node]=min(tree[2*node],tree[2*node+1]);
    }
}
ll query(ll node,ll s,ll e,ll l,ll r)
{
    if(r<s || e<l)
    {
        return 0;
    }
    if(l<=s && e<=r)
    {
        return tree[node];
    }
    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
void rangeupdate(ll node,ll s,ll e,ll l,ll r,ll val)
{
    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(s>e || s>r || e<l)
        return;

    if(l<=s && e<=r)
    {
        tree[node]+=val;
        if(s!=e)
        {
            lazy[2*node]+=val;
            lazy[2*node+1]+=val;
        }
        return;
    }

    ll mid=(s+e)/2;
    rangeupdate(2*node,s,mid,l,r,val);
    rangeupdate(2*node+1,mid+1,e,l,r,val);

    tree[node]=min(tree[2*node],tree[2*node+1]);
}
ll rangequery(ll node,ll s,ll e,ll l,ll r)
{
    if(s>e || s>r || e<l)
        return 1000000000;

    if(lazy[node]!=0)
    {
        tree[node]+=lazy[node];
        if(s!=e)
        {
            lazy[2*node]+=lazy[node];
            lazy[2*node+1]+=lazy[node];
        }
        lazy[node]=0;
    }

    if(l<=s && e<=r)
        return tree[node];

    ll mid=(s+e)/2;
    ll p1=query(2*node,s,mid,l,r);
    ll p2=query(2*node+1,mid+1,e,l,r);
    return min(p1,p2);
}
///***********************************************************************************************************************///

/*
///---------------------------------------------->DSU<--------------------------------------------------------------------///
void initalize(ll n)
{
    ll i;
    fs(i,1,n+1)
    {a[i]=i;si[i]=1;}
}
ll root(ll i)
{
    W(a[i]!=i)
    {
        a[i]=a[a[i]];
        i=a[i];
    }
    return i;
}
bool find(ll x,ll y)
{
    if(root(x)==root(y))
        return true;
    else
        return false;
}
void U(ll x,ll y)
{
    ll root_x=root(x);
    ll root_y=root(y);
    if(si[root_x]>si[root_y])
    {
        a[root_y]=a[root_x];
        si[root_x]+=si[root_y];
        si[root_y]=0;
    }
    else
    {
        a[root_x]=a[root_y];
        si[root_y]+=si[root_x];
        si[root_x]=0;
    }
}
///************************************************************************************************************************///

/*
///---------------------------------------------->MST(KRUSKAL)<------------------------------------------------------------///
ll kruskal(ll m)
{
    ll x,y,i;
    ll cost,mincost=0;
    fs(i,1,m+1)
    {
        x=p[i].se.fi;
        y=p[i].se.se;
        cost=p[i].fi;

        if(!find(x,y))
        {
            mincost+=cost;
            U(x,y);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///------------------------------------------------>MST(PRIM)<------------------------------------------------------------///
ll prim(ll x)
{
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll y,mincost=0;
    pll P;
    Q.push(mp(0, x));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(mark[x]==true)
            continue;

        mincost+=P.fi;
        mark[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            y=adj[x][i].se;
            if(!mark[y])
                Q.push(adj[x][i]);
        }
    }
    return mincost;
}
///***********************************************************************************************************************///

/*
///----------------------------------------------->DFS<-------------------------------------------------------------------///
ll dfs(ll root)
{
    ll i,j,k,sum=1;
    vis[root]=true;
    k=adj[root].size();
    fn(i,k)
    {
        j=adj[root][i];
        if(!vis[j])
        {
            sum+=dfs(j);
        }
    }
    return sum;
}
///***********************************************************************************************************************///

/*
///-------------------------------------------->BFS<----------------------------------------------------------------------///
void bfs(ll root)
{
    ll i,j,k,start;
    set<ll> q;
    q.insert(root);
    vis[root]=true;
    W(!q.empty())
    {
        it=q.begin();
        start=*it;
        ans.pb(start);
        q.erase(it);
        //k=adj[start].size();
        fit(it,adj[start])
        {
            j=*it;
            if(!vis[j])
            {
                vis[j]=true;
                q.insert(j);
            }
        }
    }
}
///************************************************************************************************************************///

/*
///--------------------------------------------->DIJKSTRA<-----------------------------------------------------------------///
void dijkstra(ll src)
{
    memset(vis,true,sizeof(vis));
    dis[src]=0;
    priority_queue<pll,vector<pll>,greater<pll> > Q;
    ll x,y,i,k,wt;
    pll P;
    Q.push(mp(0,src));
    W(!Q.empty())
    {
        P=Q.top();
        Q.pop();
        x=P.se;

        if(vis[x])
            continue;

        vis[x]=true;
        k=adj[x].size();
        fn(i,k)
        {
            wt=adj[x][i].se;
            y=adj[x][i].fi;
            if(dis[x]+wt<dis[y])
            {
                dis[y]=dis[x]+wt;
                Q.push(mp(dis[y],y));
            }
        }
    }
}
///***********************************************************************************************************************///

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,k,i,ans1,ans2,c,f,p;
    cin>>n>>k;
    vll a(n);
    fn(i,n)
    cin>>a[i];
    ll dp1[n/2],dp2[n/2];
    dp1[0]=0;
    dp2[0]=1;
    fs(i,1,n/2)
    {
        dp1[i]=(k-1)*dp2[i-1];
        dp2[i]=dp1[i-1]+(k-2)*dp2[i-1];
    }
    ans1=1;
    c=0;
    f=0;
    for(i=0;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans1=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans1=(ans1*dp1[c])%mod;
                else if(c>0)
                    ans1=(ans1*dp2[c])%mod;
                else if(c==0)
                {
                    if(a[i]==a[i-2])
                        {ans1=0;goto e;}
                }
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans1=(ans1*modex(k-1,c))%mod;
        else
        ans1=(ans1*(modex(k-1,c-1)*k)%mod)%mod;
    }
    e:
    ans2=1;
    c=0;
    f=0;
    for(i=1;i<n;i+=2)
    {
        if(a[i]==-1)
            c++;
        else
        {
            if(f==0)
            {
                ans2=modex(k-1,c);
                f=1;
            }
            else
            {
                if(a[i]==p && c>0)
                    ans2=(ans2*dp1[c])%mod;
                else if(c>0)
                    ans2=(ans2*dp2[c])%mod;
                else if(c==0)
                {
                    if(a[i]==a[i-2])
                    {ans2=0;goto g;}
                }
            }
            c=0;
            p=a[i];
        }
    }
    if(a[i-2]==-1)
    {
    	if(f)
        ans2=(ans2*modex(k-1,c))%mod;
        else
        ans2=(ans2*(modex(k-1,c-1)*k)%mod)%mod;
    }
    g:
    cout<<(ans1*ans2)%mod;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int N = 2e5 + 11;
const int MOD = 998244353;

int a[N],b[N];
int k;

ll v[N*4],w1[N*4],w2[N*4];
ll dp[N];

void push(int i, int l, int r)
{
    w2[i]=(w2[i]+MOD)%MOD;
    v[i+i]*=w1[i];
    v[i+i+1]*=w1[i];
    w1[i+i]*=w1[i];
    w1[i+i+1]*=w1[i];
    w2[i+i]*=w1[i];
    w2[i+i+1]*=w1[i];
    w1[i]=1;
    int mid=(l+r)>>1;
    v[i+i]=(v[i+i]+MOD+w2[i]*1ll*(mid-l+1))%MOD;
    v[i+i+1]=(v[i+i+1]+MOD+w2[i]*1ll*(r-mid))%MOD;
    w2[i+i]+=w2[i];
    w2[i+i+1]+=w2[i];
    w2[i]=0;
}

void build(int i, int l, int r)
{
    if (l==r) {v[i]=dp[l]; w1[i]=1; w2[i]=0; return;}
    w1[i]=1;
    w2[i]=0;
    int mid=(l+r)>>1;
    build(i+i,l,mid);
    build(i+i+1,mid+1,r);
    v[i]=v[i+i]+v[i+i+1];
}

void mn(ll x)
{
    push(1,1,k);
    w1[1]=x;
    v[1]*=x;
    v[1]=(v[1]+MOD)%MOD;
}

void sum(ll x)
{
    push(1,1,k);
    w2[1]=x;
    v[1]=(v[1]+x*1ll*k)%MOD;
}

void update(int i, int l, int r, int x, ll t)
{
    push(i,l,r);
    if (l==r) {w2[i]+=t; v[i]+=t; return;}
    int mid=(l+r)>>1;
    if (x<=mid) update(i+i,l,mid,x,t); else update(i+i+1,mid+1,r,x,t);
    v[i]=(v[i+i]+v[i+i+1])%MOD;
}

ll get(int i, int l, int r, int x)
{
    push(i,l,r);
    if (l==r) return v[i];
    int mid=(l+r)>>1;
    if (x<=mid) return get(i+i,l,mid,x);
    else return get(i+i+1,mid+1,r,x);
}

int n,m;

ll get()
{
    /**
    cout<<n<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<" ";
    cout<<endl;**/

    if (n==0) {return 1;}

    for (int i=1; i<=k; i++)
        dp[i]=0;
    if (a[1]==-1)
    {
        for (int i=1; i<=k; i++)
            dp[i]=1;
    } else dp[a[1]]=1;
    build(1,1,k);

    for (int i=2; i<=n; i++)
    if (a[i]==-1)
    {
        ll t=v[1];
        ///cout<<"mn -1"<<endl;
        ///cout<<"+ "<<t<<endl;
        mn(-1);
        sum(t);
    } else
    if (a[i]==a[i-1]) {return 0;} else
    {
        ///cout<<"get "<<a[i]<<" = "<<get(1,1,k,a[i])<<endl;
        ///cout<<"sum is "<<v[1]<<endl;
        ll t=(v[1]-get(1,1,k,a[i])+MOD)%MOD;
        mn(0);
        ///cout<<"mn 0 "<<endl;
        ///cout<<a[i]<<" +="<<t<<endl;
        update(1,1,k,a[i],t);
    }
    ///cout<<"!"<<v[1]<<endl;
    return v[1];
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nn;
    cin>>nn>>k;
    n=0;
    m=0;
    for (int i=1; i<=nn; i++)
    if (i%2==0) {n++; cin>>a[n];} else {m++; cin>>b[m];}
    ll ans1=get();
    n=m;
    for (int i=1; i<=n; i++)
        a[i]=b[i];
    ll ans2=get();
    cout<<(ans1*ans2)%MOD<<endl;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int N = 3e5 + 11;
const ll MOD = 998244353;

int a[N],b[N];
int k;

ll v[N*5],w1[N*5],w2[N*5];
ll dp[N];

inline void push(int i, int l, int r)
{
    v[i+i]=(v[i+i]*w1[i]+MOD)%MOD;
    v[i+i+1]=(v[i+i+1]*w1[i]+MOD)%MOD;
    w1[i+i]=(w1[i+i]*w1[i]+MOD)%MOD;
    w1[i+i+1]=(w1[i+i+1]*w1[i]+MOD)%MOD;
    w2[i+i]=(w2[i+i]*w1[i]+MOD)%MOD;
    w2[i+i+1]=(w2[i+i+1]*w1[i]+MOD)%MOD;
    w1[i]=1;
    int mid=(l+r)>>1;
    v[i+i]=(v[i+i]+w2[i]*1ll*(mid-l+1)+MOD)%MOD;
    v[i+i+1]=(v[i+i+1]+w2[i]*1ll*(r-mid)+MOD)%MOD;
    w2[i+i]=(w2[i+i]+w2[i])%MOD;
    w2[i+i+1]=(w2[i+i+1]+w2[i])%MOD;
    w2[i]=0;
    up(i);
    up(i+i);
    up(i+i+1);
}

inline void build(int i, int l, int r)
{
    if (l==r) {v[i]=dp[l]; w1[i]=1; w2[i]=0; return;}
    w1[i]=1;
    w2[i]=0;
    int mid=(l+r)>>1;
    build(i+i,l,mid);
    build(i+i+1,mid+1,r);
    v[i]=(v[i+i]+v[i+i+1])%MOD;
}

inline void mn(ll x)
{
    push(1,1,k);
    w1[1]=(x+MOD)%MOD;
    v[1]=(v[1]*x+MOD)%MOD;
}

inline void sum(ll x)
{
    push(1,1,k);
    w2[1]=(w2[1]+x+MOD)%MOD;
    v[1]=(v[1]+x*1ll*k+MOD)%MOD;
}

inline void update(int i, int l, int r, int x, ll t)
{
    push(i,l,r);
    if (l==r) {w2[i]=(w2[i]+t+MOD)%MOD; v[i]=(v[i]+t+MOD)%MOD; return;}
    int mid=(l+r)>>1;
    if (x<=mid) update(i+i,l,mid,x,t); else update(i+i+1,mid+1,r,x,t);
    v[i]=(v[i+i]+v[i+i+1])%MOD;
}

inline ll get(int i, int l, int r, int x)
{
    push(i,l,r);
    if (l==r) return v[i];
    int mid=(l+r)>>1;
    if (x<=mid) return get(i+i,l,mid,x);
    else return get(i+i+1,mid+1,r,x);
}

int n,m;

ll get()
{
    /**
    cout<<n<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<" ";
    cout<<endl;
    **/
    for (int i=1; i<=N*4-10; i++)
    {
        w1[i]=0;
        w2[i]=0;
        v[i]=0;
    }
    for (int i=1; i<=N-10; i++)
    {
        dp[i]=0;
    }

    if (n==0) {return 1;}

    for (int i=1; i<=k; i++)
        dp[i]=0;
    if (a[1]==-1)
    {
        for (int i=1; i<=k; i++)
            dp[i]=1;
    } else dp[a[1]]=1;
    build(1,1,k);

    for (int i=2; i<=n; i++)
    if (a[i]==-1)
    {
        ll t=v[1];
        ///cout<<"mn -1"<<endl;
        ///cout<<"+ "<<t<<endl;
        mn(-1);
        sum(t);
    } else
    if (a[i]==a[i-1]) {return 0;} else
    {
        ///cout<<"get "<<a[i]<<" = "<<get(1,1,k,a[i])<<endl;
        ///cout<<"sum is "<<v[1]<<endl;
        ll t=(v[1]-get(1,1,k,a[i])+MOD)%MOD;
        mn(0);
        ///cout<<"mn 0 "<<endl;
        ///cout<<a[i]<<" +="<<t<<endl;
        update(1,1,k,a[i],t);
    }
    ///cout<<"!"<<v[1]<<endl;
    return v[1];
}

ll res;

void dfs(int l)
{
    if (l==n+1)
    {
        res++;
        return;
    }
    if (a[l]!=-1)
    {
        if (a[l-1]==a[l]) return;
        dfs(l+1);
    } else
    {
        for (int i=1; i<=k; i++)
            if (i!=a[l-1])
        {
            a[l]=i;
            dfs(l+1);
        }
        a[l]=-1;
    }
}

ll gets()
{
    res=0;
    dfs(1);
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int nn;
    cin>>nn>>k;
    n=0;
    m=0;
    for (int i=1; i<=nn; i++)
    if (i%2==0) {n++; cin>>a[n];} else {m++; cin>>b[m];}
    ll ans1=get();
    n=m;
    for (int i=1; i<=n; i++)
        a[i]=b[i];
    ll ans2=get();
    cout<<(ans1*ans2)%MOD<<endl;

    /**
    cin>>n>>k;
    while (1)
    {
        for (int i=1; i<=n; i++)
        {
            a[i]=(rand()%(k+1));
            if (a[i]==0) a[i]=-1;
        }
        int p1=get();
        int p2=gets();
        if (p1!=p2)
        {
            for (int i=1; i<=n; i++)
                cout<<a[i]<<" ";
            cout<<endl;
            cout<<get()<<" "<<gets()<<endl;
            return 0;
        }
        cout<<"+"<<endl;
    }
    **/
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int N = 2e5 + 11;
const ll MOD = 998244353;

int a[N],b[N];
int k;

ll v[N*5],w1[N*5],w2[N*5];
ll dp[N];

inline void up(int i)
{
    v[i]=(v[i]+MOD)%MOD;
    w1[i]=(w1[i]+MOD)%MOD;
    w2[i]=(w2[i]+MOD)%MOD;
    w1[i]=(w1[i]+MOD)%MOD;
    w2[i]=(w2[i]+MOD)%MOD;
    v[i]=(v[i]+MOD)%MOD;
}

void push(int i, int l, int r)
{
    up(i);
    v[i+i]*=w1[i];
    v[i+i+1]*=w1[i];
    w1[i+i]*=w1[i];
    w1[i+i+1]*=w1[i];
    w2[i+i]*=w1[i];
    w2[i+i+1]*=w1[i];
    w1[i]=1;
    int mid=(l+r)>>1;
    v[i+i]+=w2[i]*1ll*(mid-l+1);
    v[i+i+1]+=w2[i]*1ll*(r-mid);
    w2[i+i]+=w2[i];
    w2[i+i+1]+=w2[i];
    w2[i]=0;
    up(i+i);
    up(i+i+1);
}

void build(int i, int l, int r)
{
    if (l==r) {v[i]=dp[l]; w1[i]=1; w2[i]=0; return;}
    w1[i]=1;
    w2[i]=0;
    int mid=(l+r)>>1;
    build(i+i,l,mid);
    build(i+i+1,mid+1,r);
    v[i]=v[i+i]+v[i+i+1];
}

void mn(ll x)
{
    push(1,1,k);
    w1[1]=x;
    v[1]*=x;
    up(1);
}

void sum(ll x)
{
    push(1,1,k);
    w2[1]=x;
    v[1]+=x*1ll*k;
    up(1);
}

void update(int i, int l, int r, int x, ll t)
{
    push(i,l,r);
    if (l==r) {w2[i]+=t; v[i]+=t; up(i); return;}
    int mid=(l+r)>>1;
    if (x<=mid) update(i+i,l,mid,x,t); else update(i+i+1,mid+1,r,x,t);
    v[i]=v[i+i]+v[i+i+1];
    up(i);
}

ll get(int i, int l, int r, int x)
{
    push(i,l,r);
    if (l==r) return v[i];
    int mid=(l+r)>>1;
    if (x<=mid) return get(i+i,l,mid,x);
    else return get(i+i+1,mid+1,r,x);
}

int n,m;

ll get()
{
    /**
    cout<<n<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<" ";
    cout<<endl;**/

    if (n==0) {return 1;}

    for (int i=1; i<=k; i++)
        dp[i]=0;
    if (a[1]==-1)
    {
        for (int i=1; i<=k; i++)
            dp[i]=1;
    } else dp[a[1]]=1;
    build(1,1,k);

    for (int i=2; i<=n; i++)
    if (a[i]==-1)
    {
        ll t=v[1];
        ///cout<<"mn -1"<<endl;
        ///cout<<"+ "<<t<<endl;
        mn(-1);
        sum(t);
    } else
    if (a[i]==a[i-1]) {return 0;} else
    {
        ///cout<<"get "<<a[i]<<" = "<<get(1,1,k,a[i])<<endl;
        ///cout<<"sum is "<<v[1]<<endl;
        ll t=(v[1]-get(1,1,k,a[i])+MOD)%MOD;
        mn(0);
        ///cout<<"mn 0 "<<endl;
        ///cout<<a[i]<<" +="<<t<<endl;
        update(1,1,k,a[i],t);
    }
    ///cout<<"!"<<v[1]<<endl;
    return v[1];
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nn;
    cin>>nn>>k;
    n=0;
    m=0;
    for (int i=1; i<=nn; i++)
    if (i%2==0) {n++; cin>>a[n];} else {m++; cin>>b[m];}
    ll ans1=get();
    n=m;
    for (int i=1; i<=n; i++)
        a[i]=b[i];
    ll ans2=get();
    cout<<(ans1*ans2)%MOD<<endl;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int N = 3e5 + 11;
const ll MOD = 998244353;

int a[N],b[N];
int k;

ll v[N*5],w1[N*5],w2[N*5];
ll dp[N];

inline void up(int i)
{
    v[i]=(v[i]+MOD)%MOD;
    v[i]=(v[i]+MOD)%MOD;
    w1[i]=(w1[i]+MOD)%MOD;
    w1[i]=(w1[i]+MOD)%MOD;
    w2[i]=(w2[i]+MOD)%MOD;
    w2[i]=(w2[i]+MOD)%MOD;
}

void push(int i, int l, int r)
{
    up(i);
    up(i+i);
    up(i+i+1);
    v[i+i]*=w1[i];
    v[i+i+1]*=w1[i];
    w1[i+i]*=w1[i];
    w1[i+i+1]*=w1[i];
    w2[i+i]*=w1[i];
    w2[i+i+1]*=w1[i];
    w1[i]=1;
    up(i+i);
    up(i+i+1);
    int mid=(l+r)>>1;
    v[i+i]+=w2[i]*1ll*(mid-l+1);
    v[i+i+1]+=w2[i]*1ll*(r-mid);
    w2[i+i]+=w2[i];
    w2[i+i+1]+=w2[i];
    w2[i]=0;
    up(i+i);
    up(i+i+1);
}

void build(int i, int l, int r)
{
    if (l==r) {v[i]=dp[l]; w1[i]=1; w2[i]=0; up(i); return;}
    w1[i]=1;
    w2[i]=0;
    int mid=(l+r)>>1;
    build(i+i,l,mid);
    build(i+i+1,mid+1,r);
    v[i]=v[i+i]+v[i+i+1];
    up(i);
}

void mn(ll x)
{
    push(1,1,k);
    w1[1]=x;
    v[1]*=x;
    up(1);
}

void sum(ll x)
{
    push(1,1,k);
    w2[1]+=x;
    v[1]+=x*1ll*k;
    up(1);
}

void update(int i, int l, int r, int x, ll t)
{
    push(i,l,r);
    if (l==r) {w2[i]+=t; v[i]+=t; up(i); return;}
    int mid=(l+r)>>1;
    if (x<=mid) update(i+i,l,mid,x,t); else update(i+i+1,mid+1,r,x,t);
    v[i]=v[i+i]+v[i+i+1];
    up(i);
}

ll get(int i, int l, int r, int x)
{
    push(i,l,r);
    if (l==r) return v[i];
    int mid=(l+r)>>1;
    if (x<=mid) return get(i+i,l,mid,x);
    else return get(i+i+1,mid+1,r,x);
}

int n,m;

ll get()
{
    /**
    cout<<n<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<" ";
    cout<<endl;
    **/
    for (int i=1; i<=N*4-10; i++)
    {
        w1[i]=0;
        w2[i]=0;
        v[i]=0;
    }
    for (int i=1; i<=N-10; i++)
    {
        dp[i]=0;
    }

    if (n==0) {return 1;}

    for (int i=1; i<=k; i++)
        dp[i]=0;
    if (a[1]==-1)
    {
        for (int i=1; i<=k; i++)
            dp[i]=1;
    } else dp[a[1]]=1;
    build(1,1,k);

    for (int i=2; i<=n; i++)
    if (a[i]==-1)
    {
        ll t=v[1];
        ///cout<<"mn -1"<<endl;
        ///cout<<"+ "<<t<<endl;
        mn(-1);
        sum(t);
    } else
    if (a[i]==a[i-1]) {return 0;} else
    {
        ///cout<<"get "<<a[i]<<" = "<<get(1,1,k,a[i])<<endl;
        ///cout<<"sum is "<<v[1]<<endl;
        ll t=(v[1]-get(1,1,k,a[i])+MOD)%MOD;
        mn(0);
        ///cout<<"mn 0 "<<endl;
        ///cout<<a[i]<<" +="<<t<<endl;
        update(1,1,k,a[i],t);
    }
    ///cout<<"!"<<v[1]<<endl;
    return v[1];
}

ll res;

void dfs(int l)
{
    if (l==n+1)
    {
        res++;
        return;
    }
    if (a[l]!=-1)
    {
        if (a[l-1]==a[l]) return;
        dfs(l+1);
    } else
    {
        for (int i=1; i<=k; i++)
            if (i!=a[l-1])
        {
            a[l]=i;
            dfs(l+1);
        }
        a[l]=-1;
    }
}

ll gets()
{
    res=0;
    dfs(1);
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int nn;
    cin>>nn>>k;
    n=0;
    m=0;
    for (int i=1; i<=nn; i++)
    if (i%2==0) {n++; cin>>a[n];} else {m++; cin>>b[m];}
    ll ans1=get();
    n=m;
    for (int i=1; i<=n; i++)
        a[i]=b[i];
    ll ans2=get();
    cout<<(ans1*ans2)%MOD<<endl;

    /**
    cin>>n>>k;
    while (1)
    {
        for (int i=1; i<=n; i++)
        {
            a[i]=(rand()%(k+1));
            if (a[i]==0) a[i]=-1;
        }
        int p1=get();
        int p2=gets();
        if (p1!=p2)
        {
            for (int i=1; i<=n; i++)
                cout<<a[i]<<" ";
            cout<<endl;
            cout<<get()<<" "<<gets()<<endl;
            return 0;
        }
        cout<<"+"<<endl;
    }
    **/
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int N = 3e5 + 11;
const ll MOD = 998244353;

int a[N],b[N];
int k;

ll v[N*5],w1[N*5],w2[N*5];
ll dp[N];

inline void push(int i, int l, int r)
{
    v[i+i]=(v[i+i]*w1[i]+MOD)%MOD;
    v[i+i+1]=(v[i+i+1]*w1[i]+MOD)%MOD;
    w1[i+i]=(w1[i+i]*w1[i]+MOD)%MOD;
    w1[i+i+1]=(w1[i+i+1]*w1[i]+MOD)%MOD;
    w2[i+i]=(w2[i+i]*w1[i]+MOD)%MOD;
    w2[i+i+1]=(w2[i+i+1]*w1[i]+MOD)%MOD;
    w1[i]=1;
    int mid=(l+r)>>1;
    v[i+i]=(v[i+i]+w2[i]*1ll*(mid-l+1)+MOD)%MOD;
    v[i+i+1]=(v[i+i+1]+w2[i]*1ll*(r-mid)+MOD)%MOD;
    w2[i+i]=(w2[i+i]+w2[i])%MOD;
    w2[i+i+1]=(w2[i+i+1]+w2[i])%MOD;
    w2[i]=0;
}

inline void build(int i, int l, int r)
{
    if (l==r) {v[i]=dp[l]; w1[i]=1; w2[i]=0; return;}
    w1[i]=1;
    w2[i]=0;
    int mid=(l+r)>>1;
    build(i+i,l,mid);
    build(i+i+1,mid+1,r);
    v[i]=(v[i+i]+v[i+i+1])%MOD;
}

inline void mn(ll x)
{
    push(1,1,k);
    w1[1]=(x+MOD)%MOD;
    v[1]=(v[1]*x+MOD)%MOD;
}

inline void sum(ll x)
{
    push(1,1,k);
    w2[1]=(w2[1]+x+MOD)%MOD;
    v[1]=(v[1]+x*1ll*k+MOD)%MOD;
}

inline void update(int i, int l, int r, int x, ll t)
{
    push(i,l,r);
    if (l==r) {w2[i]=(w2[i]+t+MOD)%MOD; v[i]=(v[i]+t+MOD)%MOD; return;}
    int mid=(l+r)>>1;
    if (x<=mid) update(i+i,l,mid,x,t); else update(i+i+1,mid+1,r,x,t);
    v[i]=(v[i+i]+v[i+i+1])%MOD;
}

inline ll get(int i, int l, int r, int x)
{
    push(i,l,r);
    if (l==r) return v[i];
    int mid=(l+r)>>1;
    if (x<=mid) return get(i+i,l,mid,x);
    else return get(i+i+1,mid+1,r,x);
}

int n,m;

ll get()
{
    /**
    cout<<n<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<" ";
    cout<<endl;
    **/
    for (int i=1; i<=N*4-10; i++)
    {
        w1[i]=0;
        w2[i]=0;
        v[i]=0;
    }
    for (int i=1; i<=N-10; i++)
    {
        dp[i]=0;
    }

    if (n==0) {return 1;}

    for (int i=1; i<=k; i++)
        dp[i]=0;
    if (a[1]==-1)
    {
        for (int i=1; i<=k; i++)
            dp[i]=1;
    } else dp[a[1]]=1;
    build(1,1,k);

    for (int i=2; i<=n; i++)
    if (a[i]==-1)
    {
        ll t=v[1];
        ///cout<<"mn -1"<<endl;
        ///cout<<"+ "<<t<<endl;
        mn(-1);
        sum(t);
    } else
    if (a[i]==a[i-1]) {return 0;} else
    {
        ///cout<<"get "<<a[i]<<" = "<<get(1,1,k,a[i])<<endl;
        ///cout<<"sum is "<<v[1]<<endl;
        ll t=(v[1]-get(1,1,k,a[i])+MOD)%MOD;
        mn(0);
        ///cout<<"mn 0 "<<endl;
        ///cout<<a[i]<<" +="<<t<<endl;
        update(1,1,k,a[i],t);
    }
    ///cout<<"!"<<v[1]<<endl;
    return v[1];
}

ll res;

void dfs(int l)
{
    if (l==n+1)
    {
        res++;
        return;
    }
    if (a[l]!=-1)
    {
        if (a[l-1]==a[l]) return;
        dfs(l+1);
    } else
    {
        for (int i=1; i<=k; i++)
            if (i!=a[l-1])
        {
            a[l]=i;
            dfs(l+1);
        }
        a[l]=-1;
    }
}

ll gets()
{
    res=0;
    dfs(1);
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int nn;
    cin>>nn>>k;
    n=0;
    m=0;
    for (int i=1; i<=nn; i++)
    if (i%2==0) {n++; cin>>a[n];} else {m++; cin>>b[m];}
    ll ans1=get();
    n=m;
    for (int i=1; i<=n; i++)
        a[i]=b[i];
    ll ans2=get();
    cout<<(ans1*ans2)%MOD<<endl;

    /**
    cin>>n>>k;
    while (1)
    {
        for (int i=1; i<=n; i++)
        {
            a[i]=(rand()%(k+1));
            if (a[i]==0) a[i]=-1;
        }
        int p1=get();
        int p2=gets();
        if (p1!=p2)
        {
            for (int i=1; i<=n; i++)
                cout<<a[i]<<" ";
            cout<<endl;
            cout<<get()<<" "<<gets()<<endl;
            return 0;
        }
        cout<<"+"<<endl;
    }
    **/
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

const int N = 2e5 + 11;
const int MOD = 998244353;

int a[N],b[N];
int k;

ll v[N*5],w1[N*5],w2[N*5];
ll dp[N];

inline void up(int i)
{
    v[i]=(v[i]+MOD)%MOD;
    w1[i]=(w1[i]+MOD)%MOD;
    w2[i]=(w2[i]+MOD)%MOD;
}

void push(int i, int l, int r)
{
    v[i+i]*=w1[i];
    v[i+i+1]*=w1[i];
    w1[i+i]*=w1[i];
    w1[i+i+1]*=w1[i];
    w2[i+i]*=w1[i];
    w2[i+i+1]*=w1[i];
    w1[i]=1;
    int mid=(l+r)>>1;
    v[i+i]=(v[i+i]+MOD+w2[i]*1ll*(mid-l+1))%MOD;
    v[i+i+1]=(v[i+i+1]+MOD+w2[i]*1ll*(r-mid))%MOD;
    w2[i+i]+=w2[i];
    w2[i+i+1]+=w2[i];
    w2[i]=0;
    up(i+i);
    up(i+i+1);
}

void build(int i, int l, int r)
{
    if (l==r) {v[i]=dp[l]; w1[i]=1; w2[i]=0; return;}
    w1[i]=1;
    w2[i]=0;
    int mid=(l+r)>>1;
    build(i+i,l,mid);
    build(i+i+1,mid+1,r);
    v[i]=v[i+i]+v[i+i+1];
}

void mn(ll x)
{
    push(1,1,k);
    w1[1]=x;
    v[1]*=x;
    v[1]=(v[1]+MOD)%MOD;
    up(1);
}

void sum(ll x)
{
    push(1,1,k);
    w2[1]=x;
    v[1]=(v[1]+x*1ll*k)%MOD;
    up(1);
}

void update(int i, int l, int r, int x, ll t)
{
    push(i,l,r);
    if (l==r) {w2[i]+=t; v[i]+=t; up(i); return;}
    int mid=(l+r)>>1;
    if (x<=mid) update(i+i,l,mid,x,t); else update(i+i+1,mid+1,r,x,t);
    v[i]=(v[i+i]+v[i+i+1])%MOD;
}

ll get(int i, int l, int r, int x)
{
    push(i,l,r);
    if (l==r) return v[i];
    int mid=(l+r)>>1;
    if (x<=mid) return get(i+i,l,mid,x);
    else return get(i+i+1,mid+1,r,x);
}

int n,m;

ll get()
{
    /**
    cout<<n<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<" ";
    cout<<endl;**/

    if (n==0) {return 1;}

    for (int i=1; i<=k; i++)
        dp[i]=0;
    if (a[1]==-1)
    {
        for (int i=1; i<=k; i++)
            dp[i]=1;
    } else dp[a[1]]=1;
    build(1,1,k);

    for (int i=2; i<=n; i++)
    if (a[i]==-1)
    {
        ll t=v[1];
        ///cout<<"mn -1"<<endl;
        ///cout<<"+ "<<t<<endl;
        mn(-1);
        sum(t);
    } else
    if (a[i]==a[i-1]) {return 0;} else
    {
        ///cout<<"get "<<a[i]<<" = "<<get(1,1,k,a[i])<<endl;
        ///cout<<"sum is "<<v[1]<<endl;
        ll t=(v[1]-get(1,1,k,a[i])+MOD)%MOD;
        mn(0);
        ///cout<<"mn 0 "<<endl;
        ///cout<<a[i]<<" +="<<t<<endl;
        update(1,1,k,a[i],t);
    }
    ///cout<<"!"<<v[1]<<endl;
    return v[1];
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nn;
    cin>>nn>>k;
    n=0;
    m=0;
    for (int i=1; i<=nn; i++)
    if (i%2==0) {n++; cin>>a[n];} else {m++; cin>>b[m];}
    ll ans1=get();
    n=m;
    for (int i=1; i<=n; i++)
        a[i]=b[i];
    ll ans2=get();
    cout<<(ans1*ans2)%MOD<<endl;
}


#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define pb push_back
typedef long long ll;
const ll N=3e5+7;
const ll mod= 998244353;
ll n,k;
ll a[N];

ll f[N];//以某数结尾
ll g[N];//不以某数结尾
ll c[N];
ll h[N];
ll ans;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
	cin>>n>>k;;
	for (int i=1;i<=n;i++)
	{
			cin>>a[i];
			if (a[i]==a[i-2])
			{
				puts("0");
				exit(0);

			}
		//	f[i]=1;
		//	g[i]=1;
	}
	ll kk=powmod(k,mod-2);
	ll kk1=powmod(k-1,mod-2);
	ans=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]==-1)
		{
			if (i<=2)
			{

				h[i]=k;
			}
			else
			{
				c[i]=c[i-2];
				if (c[i]==0)
				{
					h[i]=h[i-2]*(k-1)%mod;
				}
				else
				{
					f[i]=g[i-2];
					g[i]=f[i-2]*(k-1)%mod+g[i-2]*(k-2)%mod;
					g[i]%=mod;
				}

			}
		}
		else
		{
			c[i]=a[i];
			f[i]=1;
			if (a[i-2]==-1)
			{
				if (c[i-2]==0) ans=max(((ans*h[i-2]%mod)*(k-1)%mod)*kk%mod,(h[i-2]*(k-1)%mod)*kk%mod);
				else
				{
					if (a[i]==c[i-2]) ans=max(ans*g[i-2]%mod,g[i-2]);
					else
					{
						if (a[i-4]==-1)
						ans=max(ans*(f[i-2]+(g[i-2]*(k-1)%mod)*kk%mod)%mod,f[i-2]+(g[i-2]*(k-1)%mod)*kk%mod);
						else
						ans=max(ans*((g[i-2]*(k-2)%mod*kk1)%mod)%mod,(g[i-2]*(k-2)%mod)*kk1%mod);
						ans%=mod;
					}
				}

			}
		}
		//cout<<i<<" "<<f[i]<<" "<<g[i]<<" "<<ans<<endl;
	}
	if (a[n]==-1)
	{
		if (c[n]==0) ans=max(ans*h[n]%mod,h[n]);
		else ans=max(ans*(f[n]+g[n])%mod,f[n]+g[n]);
		ans%=mod;
	}
	if (a[n-1]==-1)
	{
		if (c[n-1]==0) ans=max(ans*h[n-1]%mod,h[n-1]);
		else ans=max(ans*(f[n-1]+g[n-1])%mod,f[n-1]+g[n-1]);
	}
	cout<<ans%mod<<endl;
}


#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define pb push_back
typedef long long ll;
const ll N=3e5+7;
const ll mod= 998244353;
ll n,k;
ll a[N];

ll f[N];//以某数结尾
ll g[N];//不以某数结尾
ll c[N];
ll h[N];
ll ans;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
	cin>>n>>k;;
	for (int i=1;i<=n;i++)
	{
			cin>>a[i];
		//	f[i]=1;
		//	g[i]=1;
	}
	ll kk=powmod(k,mod-2);
	ll kk1=powmod(k-1,mod-2);
	ans=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]==-1)
		{
			if (i<=2)
			{

				h[i]=k;
			}
			else
			{
				c[i]=c[i-2];
				if (c[i]==0)
				{
					h[i]=h[i-2]*(k-1)%mod;
				}
				else
				{
					f[i]=g[i-2];
					g[i]=f[i-2]*(k-1)%mod+g[i-2]*(k-2)%mod;
					g[i]%=mod;
				}

			}
		}
		else
		{
			c[i]=a[i];
			f[i]=1;
			if (a[i-2]==-1)
			{
				if (c[i-2]==0) ans=max(((ans*h[i-2]%mod)*(k-1)%mod)*kk%mod,(h[i-2]*(k-1)%mod)*kk%mod);
				else
				{
					if (a[i]==c[i-2]) ans=max(ans*g[i-2]%mod,g[i-2]);
					else
					{
						if (a[i-4]==-1)
						ans=max(ans*(f[i-2]+(g[i-2]*(k-1)%mod)*kk%mod)%mod,f[i-2]+(g[i-2]*(k-1)%mod)*kk%mod);
						else
						ans=max(ans*((g[i-2]*(k-2)%mod*kk1)%mod)%mod,(g[i-2]*(k-2)%mod)*kk1%mod);
						ans%=mod;
					}
				}

			}
		}
		//cout<<i<<" "<<f[i]<<" "<<g[i]<<" "<<ans<<endl;
	}
	if (a[n]==-1)
	{
		if (c[n]==0) ans=max(ans*h[n]%mod,h[n]);
		else ans=max(ans*(f[n]+g[n])%mod,f[n]+g[n]);
		ans%=mod;
	}
	if (a[n-1]==-1)
	{
		if (c[n-1]==0) ans=max(ans*h[n-1]%mod,h[n-1]);
		else ans=max(ans*(f[n-1]+g[n-1])%mod,f[n-1]+g[n-1]);
	}
	cout<<ans%mod<<endl;
}


#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define pb push_back
typedef long long ll;
const ll N=3e5+7;
const ll mod= 998244353;
ll n,k;
ll a[N];

ll f[N];//以某数结尾
ll g[N];//不以某数结尾
ll c[N];
ll h[N];
ll ans;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
	cin>>n>>k;;
	for (int i=1;i<=n;i++)
	{
			cin>>a[i];
			if (a[i]==a[i-2] && a[i]!=-1)
			{
				puts("0");
				exit(0);

			}
		//	f[i]=1;
		//	g[i]=1;
	}
	ll kk=powmod(k,mod-2);
	ll kk1=powmod(k-1,mod-2);
	ans=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]==-1)
		{
			if (i<=2)
			{

				h[i]=k;
			}
			else
			{
				c[i]=c[i-2];
				if (c[i]==0)
				{
					h[i]=h[i-2]*(k-1)%mod;
				}
				else
				{
					f[i]=g[i-2];
					g[i]=f[i-2]*(k-1)%mod+g[i-2]*(k-2)%mod;
					g[i]%=mod;
				}

			}
		}
		else
		{
			c[i]=a[i];
			f[i]=1;
			if (a[i-2]==-1)
			{
				if (c[i-2]==0) ans=max(((ans*h[i-2]%mod)*(k-1)%mod)*kk%mod,(h[i-2]*(k-1)%mod)*kk%mod);
				else
				{
					if (a[i]==c[i-2]) ans=max(ans*g[i-2]%mod,g[i-2]);
					else
					{
						if (a[i-4]==-1)
						ans=max(ans*(f[i-2]+(g[i-2]*(k-1)%mod)*kk%mod)%mod,f[i-2]+(g[i-2]*(k-1)%mod)*kk%mod);
						else
						ans=max(ans*((g[i-2]*(k-2)%mod*kk1)%mod)%mod,(g[i-2]*(k-2)%mod)*kk1%mod);
						ans%=mod;
					}
				}

			}
		}
		//cout<<i<<" "<<f[i]<<" "<<g[i]<<" "<<ans<<endl;
	}
	if (a[n]==-1)
	{
		if (c[n]==0) ans=max(ans*h[n]%mod,h[n]);
		else ans=max(ans*(f[n]+g[n])%mod,f[n]+g[n]);
		ans%=mod;
	}
	if (a[n-1]==-1)
	{
		if (c[n-1]==0) ans=max(ans*h[n-1]%mod,h[n-1]);
		else ans=max(ans*(f[n-1]+g[n-1])%mod,f[n-1]+g[n-1]);
	}
	cout<<ans%mod<<endl;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
#define ll long long
#define pb push_back
vector<ll>u,v;
const ll p=998244353;
ll f[maxn],g[maxn];

ll qpow(ll a,ll b){
	ll res=1,temp=a%p;
	while (b>0){
		if (b&1) res=res*temp%p;
		temp=temp*temp%p;
		b>>=1;
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;

	for (int i=1;i<=n;i++){
		ll x;
		cin>>x;
		if (i%2) v.pb(x);
		else u.pb(x);
	}
	ll ans1=1,ans2=1;
	n=v.size();
	int l=0,r;
	while (l<n){
		while (l<n&&v[l]!=-1){
			if (l>0&&v[l]==v[l-1]) ans1=0;
			l++;
		}
		if (l==n) break;
		r=l;
		while (r<n&&v[r]==-1) r++;

		if (l==0&&r==n){
			ans1=ans1*k%p*qpow(k-1,r-l-1)%p;
			l=r;
			continue;
		}
		if (r==n){
			ans1=ans1*qpow(k-1,r-l)%p;
			l=r;
			continue;
		}

		if (l==0){
			f[l]=k-1;
			g[l]=1;
		}else if (v[l-1]!=v[r]){
			f[l]=k-2;
			g[l]=1;
		}else{
			f[l]=k-1;
			g[l]=0;
		}

		for (int i=l+1;i<r;i++){
			f[i]=(f[i-1]*(k-2)+g[i-1]*(k-1))%p;
			g[i]=f[i-1];
		}

		if (r==n){
			ans1=ans1*(f[r-1]+g[r-1])%p;
		}else{
			ans1=ans1*f[r-1]%p;
		}
		l=r;
	}

	n=u.size();
	l=0,r;
	while (l<n){
		while (l<n&&u[l]!=-1){
			if (l>0&&u[l]==u[l-1]) ans2=0;
			l++;
		}

		if (l==n) break;
		r=l;

		while (r<n&&u[r]==-1) r++;

		if (l==0&&r==n){
			ans2=ans2*k%p*qpow(k-1,r-l-1)%p;
			l=r;
			continue;
		}
		if (r==n){
			ans2=ans2*qpow(k-1,r-l)%p;
			l=r;
			continue;
		}

		if (l==0){
			f[l]=k-1;
			g[l]=1;
		}else if (u[l-1]!=u[r]){
			f[l]=k-2;
			g[l]=1;
		}else{
			f[l]=k-1;
			g[l]=0;
		}
		for (int i=l+1;i<r;i++){
			f[i]=(f[i-1]*(k-2)+g[i-1]*(k-1))%p;
			g[i]=f[i-1];
		}
		if (r==n){
			ans2=ans2*(f[r-1]+g[r-1])%p;
		}else{
			ans2=ans2*f[r-1]%p;
		}
		l=r;
	}
	cout<<ans1*ans2%p<<endl;

}

/*

fi:最后一个不是x的方案数
gi:最后一个是x的方案数
fi=f(i-1)*(k-2)+g(i-1)*(k-1)
gi=f(i-1)

-1 -1 3

3 -4
!3 -3*4=12

*/


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
#define ll long long
#define pb push_back
ll a[maxn];
vector<ll>u,v;
const ll p=998244353;

int main(){
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;

	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (i%2) v.pb(a[i]);
		else u.pb(a[i]);
	}
	ll cnt1=1,cnt2=1;
	for (int i=0;i<v.size();i++){
		if (v[i]!=-1){
			if (i>0&&v[i]==v[i-1]) cnt1=0;
			continue;
		}
		ll cnt=k;
		if (i>0) cnt--;
		if (i+1<v.size()&&v[i+1]!=-1) cnt--;
		cnt1=cnt1*cnt%p;
	}

	for (int i=0;i<u.size();i++){
		if (u[i]!=-1){
			if (i>0&&u[i]==u[i-1]) cnt2=0;
			continue;
		}

		ll cnt=k;
		if (i>0) cnt--;
		if (i+1<u.size()&&u[i+1]!=-1) cnt--;
		cnt2=cnt2*cnt%p;
	}

	cout<<(cnt1*cnt2)%p<<endl;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
#define ll long long
#define pb push_back
vector<ll>u,v;
const ll p=998244353;
ll f[maxn],g[maxn];

int main(){
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;

	for (int i=1;i<=n;i++){
		ll x;
		cin>>x;
		if (i%2) v.pb(x);
		else u.pb(x);
	}
	ll ans1=1,ans2=1;
	n=v.size();
	int l=0,r;
	while (l<n){
		while (l<n&&v[l]!=-1){
			if (l>0&&v[l]==v[l-1]) ans1=0;
			l++;
		}
		if (l==n) break;
		r=l;
		while (r<n&&v[r]==-1) r++;
		if (l==0){
			f[l]=k-1;
			g[l]=1;
		}else{
			f[l]=k-2;
			g[l]=1;
		}
		for (int i=l+1;i<r;i++){
			f[i]=f[i-1]*(k-2)+g[i-1]*(k-1);
			g[i]=f[i-1];
		}
		if (r==n){
			ans1=ans1*(f[r-1]+g[r-1])%p;
		}else{
			ans1=ans1*f[r-1]%p;
		}
		l=r;
	}

	n=u.size();
	l=0,r;
	while (l<n){
		while (l<n&&u[l]!=-1){
			if (l>0&&u[l]==u[l-1]) ans2=0;
			l++;
		}

		if (l==n) break;
		r=l;

		while (r<n&&u[r]==-1) r++;
		if (l==0){
			f[l]=k-1;
			g[l]=1;
		}else{
			f[l]=k-2;
			g[l]=1;
		}
		for (int i=l+1;i<r;i++){
			f[i]=f[i-1]*(k-2)+g[i-1]*(k-1);
			g[i]=f[i-1];
		}
		if (r==n){
			ans2=ans2*(f[r-1]+g[r-1])%p;
		}else{
			ans2=ans2*f[r-1]%p;
		}
		l=r;
	}
	cout<<ans1*ans2%p<<endl;

}

/*

fi:最后一个不是x的方案数
gi:最后一个是x的方案数
fi=f(i-1)*(k-2)+g(i-1)*(k-1)
gi=f(i-1)

*/


#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=2e5+5;
int k;
int get1(int a,int b,int c){
	// trace(a,b,c);
	if(a==-1&&b==-1) return mul(k,power(k-1,c-1));
	if(a==-1||b==-1) return power(k-1,c);
	if(a!=b){
		vi f(c+5);int co=power(k-1,2);
		f[1]=max(0,k-2);f[2]=co;
		for(int i=3;i<=c;i++)f[i]=mul(f[i-2],co);
		return f[c];
	}
	vi f(c+5);int co=power(k-1,2);
	f[1]=max(0,k-1);f[2]=mul(k-1,power(max(0,k-2),1));
	for(int i=3;i<=c;i++)f[i]=mul(f[i-2],co);
	return f[c];
}
int get(vi v){
	// trace(v);
	int n=v.size();
	for(int i=1;i<n;i++){
		if(v[i]>0&&v[i-1]>0&&v[i]==v[i-1])return 0;
	}
	int a=-1,f=0,ans=1;
	for(int i=0;i<n;i++){
		if((v[i]>0)&&f){ans=mul(ans,get1(a,v[i],f));f=0;a=v[i];}
		else if(v[i]>0) a=v[i];
		else f++;
	}
	if(f>0)ans=mul(ans,get1(a,-1,f));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;cin>>n>>k;
	vi v(n);for(int i=0;i<n;i++)cin>>v[i];
	vi o,e;
	for(int i=0;i<n;i++)if(i&1)o.pb(v[i]);else e.pb(v[i]);
	int ans=mul(get(o),get(e));
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=2e5+5;
int k;
int get1(int a,int b,int c){
	// trace(a,b,c);
	if(a==-1&&b==-1) return mul(k,power(k-1,c-1));
	if(a==-1||b==-1) return power(k-1,c);
	if(a!=b){
		vi f(c+5);int co=power(k-1,2);
		f[1]=max(0,k-2);f[2]=add(k-1,power(max(0,k-2),2));
		for(int i=3;i<=c;i++)f[i]=mul(f[i-2],co);
		return f[c];
	}
	vi f(c+5);int co=power(k-1,2);
	f[1]=max(0,k-1);f[2]=mul(k-1,power(max(0,k-2),1));
	for(int i=3;i<=c;i++)f[i]=mul(f[i-2],co);
	return f[c];
}
int get(vi v){
	// trace(v);
	int n=v.size();
	for(int i=1;i<n;i++){
		if(v[i]>0&&v[i-1]>0&&v[i]==v[i-1])return 0;
	}
	int a=-1,f=0,ans=1;
	for(int i=0;i<n;i++){
		if((v[i]>0)&&f){ans=mul(ans,get1(a,v[i],f));f=0;a=v[i];}
		else if(v[i]>0) a=v[i];
		else f++;
	}
	if(f>0)ans=mul(ans,get1(a,-1,f));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;cin>>n>>k;
	vi v(n);for(int i=0;i<n;i++)cin>>v[i];
	vi o,e;
	for(int i=0;i<n;i++)if(i&1)o.pb(v[i]);else e.pb(v[i]);
	int ans=mul(get(o),get(e));
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=2e5+5;
int k;
int get1(int a,int b,int c){
	// trace(a,b,c);
	if(a==-1&&b==-1) return mul(k,power(k-1,c-1));
	if(a==-1||b==-1) return power(k-1,c);
	if(a!=b){
		vi f(c+5);int co=add(k-1,power(max(0,k-2),2));
		f[1]=max(0,k-2);f[2]=co;
		for(int i=3;i<=c;i++)f[i]=mul(f[i-2],co);
		return f[c];
	}
	vi f(c+5);int co=power(k-1,2);
	f[1]=max(0,k-1);f[2]=mul(k-1,power(max(0,k-2),1));
	for(int i=3;i<=c;i++)f[i]=mul(f[i-2],co);
	return f[c];
}
int get(vi v){
	// trace(v);
	int n=v.size();
	for(int i=1;i<n;i++){
		if(v[i]>0&&v[i-1]>0&&v[i]==v[i-1])return 0;
	}
	int a=-1,f=0,ans=1;
	for(int i=0;i<n;i++){
		if((v[i]>0)&&f){ans=mul(ans,get1(a,v[i],f));f=0;a=v[i];}
		else if(v[i]>0) a=v[i];
		else f++;
	}
	if(f>0)ans=mul(ans,get1(a,-1,f));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;cin>>n>>k;
	vi v(n);for(int i=0;i<n;i++)cin>>v[i];
	vi o,e;
	for(int i=0;i<n;i++)if(i&1)o.pb(v[i]);else e.pb(v[i]);
	int ans=mul(get(o),get(e));
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=2e5+5;
int k;
int get1(int a,int b,int c){
	// trace(a,b,c);
	if(a==-1&&b==-1) return mul(k,power(k-1,c-1));
	if(a==-1||b==-1) return power(k-1,c);
	vi dp1(c+5),dp2(c+5);
	dp1[1]=max(0,k-1);dp1[2]=mul(k-1,max(0,k-2));
	dp2[1]=max(0,k-2);dp2[2]=add(k-1,power(max(0,k-2),2));
	for(int i=3;i<=c;i++){
		dp1[i]=add(mul(dp1[i-2],k-1),mul(dp2[i-2],mul(k-1,max(k-2,0))));
		dp2[i]=add(mul(dp1[i-2],max(k-2,0)),mul(dp2[i-2],add(k-1,mul(max(k-2,0),max(k-2,0)))));
	}
	if(a!=b)return dp2[c];
	return dp1[c];
}
int get(vi v){
	// trace(v);
	int n=v.size();
	for(int i=1;i<n;i++){
		if(v[i]>0&&v[i-1]>0&&v[i]==v[i-1])return 0;
	}
	int a=-1,f=0,ans=1;
	for(int i=0;i<n;i++){
		if((v[i]>0)&&f){ans=mul(ans,get1(a,v[i],f));f=0;a=v[i];}
		else if(v[i]>0) a=v[i];
		else f++;
	}
	if(f>0)ans=mul(ans,get1(a,-1,f));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;cin>>n>>k;
	vi v(n);for(int i=0;i<n;i++)cin>>v[i];
	vi o,e;
	for(int i=0;i<n;i++)if(i&1)o.pb(v[i]);else e.pb(v[i]);
	int ans=mul(get(o),get(e));
	cout<<ans<<endl;
}