#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int n,l,x,y;
int a[100010];
int l1,l2,l3,l4,head,tail,mid;
int bj1,bj2,bj3,bj4;
int main()
{

	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	l1=x;l2=y;l3=abs(x-y);l4=x+y;
	for (int i=1;i<=n;i++)
	{
		int now=a[i];
		head=1,tail=i;
		mid;
		if (a[tail]-a[head]>=x)
		{
			while (head<tail)
			{
				int mid=(head+tail)/2;
				if (now-a[mid]>x)
				 head=mid+1;
				else tail=mid;
			}
			if(now-a[head]==x)
		   		bj1=1;
		}
		head=1;tail=i;
		if (a[tail]-a[head]>=y)
		{
			while (head<tail)
			{
				int mid=(head+tail)/2;
				if (now-a[mid]>y)
				 head=mid+1;
				else tail=mid;
			}
			if(now-a[head]==y)
		   		bj2=1;

		}
		head=1;tail=i;
		if (a[tail]-a[head]>=l3&&(a[tail]>=max(y,x)||a[tail]+min(y,x)<=l))
		{
			while (head<tail)
			{
				int mid=(head+tail)/2;
				if (now-a[mid]>l3)
				 head=mid+1;
				else tail=mid;
			}
			if(now-a[head]==l3)
		   		bj3=i;
		}
		head=1;tail=i;
		if (a[tail]-a[head]>=l4)
		{
			while (head<tail)
			{
				int mid=(head+tail)/2;
				if (now-a[mid]>l4)
				 head=mid+1;
				else tail=mid;
			}
			if(now-a[head]==l4)
		   		bj4=i;
		}
	}
	if (bj1==1&&bj2==1)
	{
		printf("0");
		return 0;
	}
	if (bj1==1||bj2==1)
	{
		if (bj1==1)
		printf("1\n%d",y);
		else printf("1\n%d",x);
		return 0;
	}
	if (bj3!=0)
	{
		if (a[bj3]-max(y,x)>=0)
			printf("1\n%d",a[bj3]-max(y,x));
		else printf("1\n%d",a[bj3]+min(y,x));
		return 0;
	}
	if (bj4!=0)
	{
		printf("1\n%d",a[bj4]-x);
		return 0;
	}
	printf("2\n%d %d",x,y);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=101000;
const int mo=100007;
int n,l,x,y,dis[maxn],xx,yy,head[mo],p,yes,ans[10];
struct data
{
	int go,next;
}edge[maxn];
void build(int a,int b)
{
	p++;
	edge[p].go=b;
	edge[p].next=head[a];
	head[a]=p;
}
int can(int mm)
{
	if (mm<0) return 0;
	if (mm>l) return 0;
	return 1;
}
int F(int a,int gg)
{
	for (int i=head[a];i;i=edge[i].next)
	{
		if (edge[i].go==gg) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&dis[i]);
		int kk=dis[i] % mo;
		build(kk,dis[i]);
	}
	yes=0;
 	for (int i=1;i<=n;i++)
 	{
 		if (dis[i]+x<=l&&F((dis[i]+x)%mo,dis[i]+x)) xx++;
 		if (dis[i]-x>=0&&F((dis[i]-x)%mo,dis[i]-x)) xx++;
 		if (dis[i]+y<=l&&F((dis[i]+y)%mo,dis[i]+y)) yy++;
 		if (dis[i]-y>=0&&F((dis[i]-y)%mo,dis[i]-y)) yy++;

 	}
 	if (xx&yy)
 	{
 		printf("0");
 		exit(0);
 	}
 if (xx)
 	{
 		printf("1\n");
 		printf("%d",y);
 		exit(0);
 	}
 	if (yy)
 	{
 			printf("1\n");
 		printf("%d",x);
 		exit(0);
 	}
for (int i=1;i<=n;i++)
	{
		int mm=dis[i]-x;
	 	if (can(mm))
	 	{
	 		if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 	}
		mm=dis[i]+x;
		if (can(mm))
		{
				if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
		}
	 mm=dis[i]-y;
	 if (can(mm))
	 {
	 		if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 }
	mm=dis[i]+y;
	if (can(mm))
	{
			if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	}
	}
	printf("2\n");
	printf("%d %d\n",x,y);
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int da[100010];
int x,y,n,l;
bool erfen(int a,int b,int c)
{
	if (a==b&&da[a]!=c)return false;
	if (da[a]==c) return true;
	if (da[b]==c)return true;
	int mid=(a+b)/2;
	if (c>da[mid])return erfen(mid+1,b,c);
	else return erfen(a,mid,c);
}
int main()
{

	scanf("%d%d%d%d",&n,&l,&x,&y);
	int ans=2,yesx=0,yesy=0;
	//printf("%d\n",x);
	for (int i=1;i<=n;i++)scanf("%d",&da[i]);
	for (int i=1;i<=n;i++)
    {
    	if (erfen(1,n,da[i]+x) )
		{
			ans-=1;
			yesx=1;
			break;
		}
    }
    for (int i=1;i<=n;i++)
    {
    	if (erfen(1,n,da[i]+y) )
		{
			ans-=1;
			yesy=1;
			break;
		}
    }
    if (ans==2)
    {
    	for (int i=1;i<=n;i++)
    	{
    		if (erfen(1,n,da[i]+x-y))
    		{
    			printf("%d\n",ans-1);
    			printf("%d",da[i]+x);
    			exit(0);
    		}
    	}

    }
    if (ans==0)printf("%d\n",ans);
    if (ans==1)
	{
		printf("%d\n",ans);
		if (yesx==0)printf("%d",x);
		if (yesy==0)printf("%d",y);
	}
    if (ans==2)
	{
		if (x==y)
		{
			printf("%d\n",ans-1);
			printf("%d",x);
			exit(0);
		}
    	for (int i=1;i<=n;i++)
    	if (erfen(1,n,da[i]+x+y))
    	{

     		printf("1\n");
     		printf("%d",da[i]+x);
     		exit(0);
    	}
    	printf("2\n");
    	printf("%d %d",x,y);
    }
   	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,l,x,y,a,b,c,d;
int aa[100100];

int find(int q)
{
	int j=1;
	//printf("##%d\n",q);
	for (int i=2;i<=n;i++)
	{
		while (aa[i]-aa[j]>q) j++;
		if (aa[i]-aa[j]==q) return j;
	}
	return 0;
}
int find1(int q)
{
	int j=1;
	//printf("##%d\n",q);
	for (int i=2;i<=n;i++)
	{
		while (aa[i]-aa[j]>q) j++;
		if (aa[i]-aa[j]==q)
		{
			printf("!!\n");
			int ll=aa[j],rr=aa[i];
			if (ll-x>0)
            	return ll-x;
    		if (rr+x<l)
    			return rr+x;
    	}
	}
	return 0;
}

int main()
{

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

	scanf("%d%d%d%d",&n,&l,&x,&y);

	for (int i=1;i<=n;i++)
    	scanf("%d",&aa[i]);

    a=find(x);
    b=find(y);

    if (a&&b)
    {
        printf("0");
        return 0;
    }
   // printf("##\n");
    if (a)
    {
       printf("1\n");
       printf("%d",y);
       return 0;
    }
    //printf("##\n");
    if (b)
    {
       printf("1\n");
       //printf("%d %d\n",aa[b],aa[b]+y);
       printf("%d",x);

       return 0;
    }

    if (x+y<=l)
    c=find(x+y);
    if (c)
    {
    	printf("1\n");
    	printf("%d",aa[c]+x);
    	return 0;
    }
	d=find1(y-x);
    if (d)
    {
        printf("1\n");
    	printf("%d",d);
    	return 0;
    }
    printf("2\n");
    printf("%d %d",x,y);
    return 0;
}


#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n,l,x,y,xy;
int num[maxn],sum[maxn];

void reading()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++) scanf("%d",&num[i]);
}
bool find(int x)
{
	int l=1,r=n,mid;
	while (l!=r)
	{
		mid=(l+r)/2+1;
		if (num[mid]<=x) l=mid;
		else r=mid-1;
	};
	return num[l]==x;
}
void chuli()
{
	int h1=0,h2=0,h3=0,h4=0,ww3,ww4;
	for (int i=1;i<=n;i++)
	{
		if (find(x+num[i])) h1=1;
		if (find(y+num[i]))h2=1;
		if (find(x+y+num[i]))
		{
			h3=1;
			ww3=num[i];
		};
		if (find(y-x+num[i])&&num[i]-x>=0)
		{
			h4=1;
			ww4=num[i];
		}
	};

	if (h1&&h2)
	{
		printf("0\n");
		exit(0);
	};
	if(!h1&&h2)
	{
		printf("1\n");
		printf("%d\n",x);
		exit(0);
	};
	if(h1&&!h2)
	{
		printf("1\n");
		printf("%d\n",y);
		exit(0);
	};
	if (h3)
	{
		printf("1\n");
		printf("%d\n",ww3+x);
		exit(0);
	};
	if (h4)
	{
		printf("1\n");
		printf("%d\n",ww4-x);
		exit(0);
	};
	printf("2\n");
	printf("%d %d\n",x,y);
};
int main()
{
	reading();
	chuli();
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
int n,l,x,y,k[100010];
map<int,bool>bj;
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);int xx=1,yy=1,zz=-1;
	for(int i=1;i<=n;i++) scanf("%d",&k[i]),bj[k[i]]=1;
	for(int i=1;i<=n;i++)
	{
		if(bj[k[i]+x]) xx=0;
		if(bj[k[i]+y]) yy=0;
		if(bj[k[i]-x+y]) if(k[i]-x>=0) zz=k[i]-x;
		if(bj[k[i]-y+x]) if(k[i]-y>=0) zz=k[i]-y;
		if(bj[k[i]-x-y]) if(k[i]-x-y>=0) zz=k[i]-x;
		if(bj[k[i]+x+y]) if(k[i]+x+y<=l) zz=k[i]+x;
		if(bj[k[i]+x]&&bj[k[i]-y]) xx=yy=0;
		if(bj[k[i]-y]&&bj[k[i]+x]) xx=yy=0;
	}
	int ans=xx+yy;
	if(ans==2)
	{
		if(zz!=-1) printf("1\n%d",zz);
		else printf("2\n%d %d\n",x,y);
	}
	if(ans==1)
	{
		if(yy) printf("1\n%d\n",y);
		else printf("1\n%d\n",x);
	}
	if(ans==0)
	printf("0\n");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=101000;
const int mo=100007;
int n,l,x,y,dis[maxn],xx,yy,head[mo+1002],p,yes,ans[10];
struct data
{
	int go,next;
}edge[maxn];
void build(int a,int b)
{
	p++;
	edge[p].go=b;
	edge[p].next=head[a];
	head[a]=p;
}
int can(int mm)
{
	if (mm<0) return 0;
	if (mm>l) return 0;
	return 1;
}
int F(int a,int gg)
{
	for (int i=head[a];i;i=edge[i].next)
	{
		if (edge[i].go==gg) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&dis[i]);
		int kk=dis[i] % mo;
		build(kk,dis[i]);
	}
	yes=0;
 	for (int i=1;i<=n;i++)
 	{
 		if (dis[i]+x<=l&&F((dis[i]+x)%mo,dis[i]+x)) xx++;
 		if (dis[i]-x>=0&&F((dis[i]-x)%mo,dis[i]-x)) xx++;
 		if (dis[i]+y<=l&&F((dis[i]+y)%mo,dis[i]+y)) yy++;
 		if (dis[i]-y>=0&&F((dis[i]-y)%mo,dis[i]-y)) yy++;
 	}
 	if (xx>0&yy>0)
 	{
 		printf("0");
 		exit(0);
 	}
 if (xx)
 	{
 		printf("1\n");
 		printf("%d",y);
 		exit(0);
 	}
 	if (yy)
 	{
 		printf("1\n");
 		printf("%d",x);
 		exit(0);
 	}
for (int i=1;i<=n;i++)
	{
		int mm=dis[i]-x;
	 	if (can(mm))
	 	{
	 		if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 	}
		mm=dis[i]+x;
		if (can(mm))
		{
				if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
		}
	 mm=dis[i]-y;
	 if (can(mm))
	 {
	 		if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 }
	mm=dis[i]+y;
	if (can(mm))
	{
			if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	}
	}
	printf("2\n");
	printf("%d %d\n",x,y);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
int n,l,x,y,k[100010];
map<int,bool>bj;
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);int xx=1,yy=1,zz=-1;
	for(int i=1;i<=n;i++) scanf("%d",&k[i]),bj[k[i]]=1;
	for(int i=1;i<=n;i++)
	{
		if(bj[k[i]+x]) xx=0;
		if(bj[k[i]+y]) yy=0;
		if(bj[k[i]-x+y]) if(k[i]-x>=0) zz=k[i]-x;
		if(bj[k[i]-y+x]) if(k[i]-y>=0) zz=k[i]-y;
		if(bj[k[i]+x+y]&&!bj[k[i]+x]) if(k[i]+x+y<=l) zz=k[i]+x;
		if(bj[k[i]+x+y]&&!bj[k[i]+y]) if(k[i]+x+y<=l) zz=k[i]+y;
		if(bj[k[i]+x]&&bj[k[i]-y]) xx=yy=0;
		if(bj[k[i]-y]&&bj[k[i]+x]) xx=yy=0;
	}
	int ans=xx+yy;
	if(ans==2)
	{
		if(zz!=-1) printf("1\n%d",zz);
		else printf("2\n%d %d\n",x,y);
	}
	if(ans==1)
	{
		if(yy) printf("1\n%d\n",y);
		else printf("1\n%d\n",x);
	}
	if(ans==0)
	printf("0\n");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int bj[100010],n,l,x,y;
bool find(int a,int b,int c)
{
	int st=a-1,en=b+1,mid;
	while(st+1 < en)
	{
		mid=(st+en)>>1;
		if(bj[mid]<c) st=mid;
		else en=mid;
	}
	return bj[en]==c;
}
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for(int i=1;i<=n;i++) scanf("%d",&bj[i]);
	sort(bj+1,bj+n+1);
	int er=1,one=1;
	for(int i=1;i<=n;i++)
	{
		if(one&&find(i,n,bj[i]+x)) one=0;
		if(er&&find(i,n,bj[i]+y)) er=0;
	}
	printf("%d\n",er+one);
	if(one) printf("%d ",x+bj[1]);
	if(er) printf("%d ",y+bj[1]);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int maxn=100100;
int n,len,x,y;
int mark[maxn],dis[maxn],que[maxn],lead,tail;
int canx,cany;

int main()
{
	scanf("%d%d%d%d",&n,&len,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&mark[i]);
		dis[i]=mark[i]-mark[i-1];
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>x) lead++;
		if (mark[que[tail]]-mark[que[lead]]==x)
		{
			canx=1;
			break;
		}
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>y) lead++;
		if (mark[que[tail]]-mark[que[lead]]==y)
		{
			cany=1;
			break;
		}
	}
	if (canx && cany)
	{
		cout<<0<<endl;
		return 0;
	}
	if (!canx && cany)
	{
		cout<<1<<endl;
		cout<<x<<endl;
		return 0;
	}
	if (canx && !cany)
	{
		cout<<1<<endl;
		cout<<y<<endl;
		return 0;
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>x+y) lead++;
		if (mark[que[tail]]-mark[que[lead]]==x+y)
		{
			cout<<1<<endl;
			cout<<mark[que[lead]]+x<<endl;
			return 0;
		}
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[lead]]<x) lead++;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>y-x) lead++;
		if (mark[que[tail]]-mark[que[lead]]==y-x)
		{
			cout<<1<<endl;
			cout<<mark[que[lead]]-x<<endl;
			return 0;
		}
	}
	cout<<2<<endl;
	cout<<x<<' '<<y<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
int n,l,x,y,k[100010];
map<int,bool>bj;
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);int xx=1,yy=1,zz=-1;
	for(int i=1;i<=n;i++) scanf("%d",&k[i]),bj[k[i]]=1;
	for(int i=1;i<=n;i++)
	{
		if(bj[k[i]+x]) xx=0;
		if(bj[k[i]+y]) yy=0;
		if(bj[k[i]+y-x]) if(k[i]+y<=l) zz=k[i]+y;
		if(bj[k[i]+x-y]) if(k[i]+x<=l) zz=k[i]+x;
		if(bj[k[i]-x+y]) if(k[i]-x>=0) zz=k[i]-x;
		if(bj[k[i]-y+x]) if(k[i]-y>=0) zz=k[i]-y;
		if(bj[k[i]+x+y]&&!bj[k[i]+x]&&!bj[k[i]+y]) if(k[i]+x+y<=l) zz=k[i]+x;
		if(bj[k[i]+x]&&bj[k[i]-y]) xx=yy=0;
		if(bj[k[i]-y]&&bj[k[i]+x]) xx=yy=0;
	}
	int ans=xx+yy;
	if(ans==2)
	{
		if(zz!=-1) printf("1\n%d",zz);
		else printf("2\n%d %d\n",x,y);
	}
	if(ans==1)
	{
		if(yy) printf("1\n%d\n",y);
		else printf("1\n%d\n",x);
	}
	if(ans==0)
	printf("0\n");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
int n,l,x,y,k[100010];
map<int,bool>bj;
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);int xx=1,yy=1,zz=-1;
	for(int i=1;i<=n;i++) scanf("%d",&k[i]),bj[k[i]]=1;
	for(int i=1;i<=n;i++)
	{
		if(bj[k[i]+x]) xx=0;
		if(bj[k[i]+y]) yy=0;
		if(bj[k[i]+y-x]) if(k[i]+y<=l) zz=k[i]+y;
		if(bj[k[i]+x-y]) if(k[i]+x<=l) zz=k[i]+x;
		if(bj[k[i]-x+y]) if(k[i]-x>=0) zz=k[i]-x;
		if(bj[k[i]-y+x]) if(k[i]-y>=0) zz=k[i]-y;
		if(bj[k[i]+x+y]&&!bj[k[i]+x]&&!bj[k[i]+y]) if(k[i]+x+y<=l) zz=k[i]+x;
	}
	int ans=xx+yy;
	if(ans==2)
	{
		if(zz!=-1) printf("1\n%d",zz);
		else printf("2\n%d %d\n",x,y);
	}
	if(ans==1)
	{
		if(yy) printf("1\n%d\n",y);
		else printf("1\n%d\n",x);
	}
	if(ans==0)
	printf("0\n");
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,l,x,y,a,b,c,d;
int aa[100100];

int find(int q)
{
	int j=1;
	//printf("##%d\n",q);
	for (int i=2;i<=n;i++)
	{
		while (aa[i]-aa[j]>q) j++;
		if (aa[i]-aa[j]==q) return j;
	}
	return 0;
}
int find1(int q)
{
	int j=1;
	//printf("##%d\n",q);
	for (int i=2;i<=n;i++)
	{
		while (aa[i]-aa[j]>q) j++;
		if (aa[i]-aa[j]==q)
		{

			int ll=aa[j],rr=aa[i];
			if (ll-x>0)
            	return ll-x;
    		if (rr+x<l)
    			return rr+x;
    	}
	}
	return 0;
}

int main()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);

	scanf("%d%d%d%d",&n,&l,&x,&y);

	for (int i=1;i<=n;i++)
    	scanf("%d",&aa[i]);

    a=find(x);
    b=find(y);

    if (a&&b)
    {
        printf("0");
        return 0;
    }
   // printf("##\n");
    if (a)
    {
       printf("1\n");
       printf("%d",y);
       return 0;
    }
    //printf("##\n");
    if (b)
    {
       printf("1\n");
       printf("%d %d\n",aa[b],aa[b]+y);
       printf("%d",x);

       return 0;
    }

    if (x+y<=l)
    c=find(x+y);
    if (c)
    {
    	printf("1\n");
    	printf("%d",aa[c]+x);
    	return 0;
    }
	d=find1(y-x);
    if (d)
    {
        printf("1\n");
    	printf("%d",d);
    	return 0;
    }
    printf("2\n");
    printf("%d %d",x,y);
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int maxn=100100;
int n,len,x,y;
int mark[maxn],dis[maxn],que[maxn],lead,tail;
int canx,cany;

int main()
{
	scanf("%d%d%d%d",&n,&len,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&mark[i]);
		dis[i]=mark[i]-mark[i-1];
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>x) lead++;
		if (mark[que[tail]]-mark[que[lead]]==x)
		{
			canx=1;
			break;
		}
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>y) lead++;
		if (mark[que[tail]]-mark[que[lead]]==y)
		{
			cany=1;
			break;
		}
	}
	if (canx && cany)
	{
		cout<<0<<endl;
		return 0;
	}
	if (!canx && cany)
	{
		cout<<1<<endl;
		cout<<x<<endl;
		return 0;
	}
	if (canx && !cany)
	{
		cout<<1<<endl;
		cout<<y<<endl;
		return 0;
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>x+y) lead++;
		if (mark[que[tail]]-mark[que[lead]]==x+y)
		{
			cout<<1<<endl;
			cout<<mark[que[lead]]+x<<endl;
			return 0;
		}
	}
	lead=1;tail=0;
	for (int i=1;i<=n;i++)
	{
		que[++tail]=i;
		while (lead<=tail && mark[que[tail]]-mark[que[lead]]>y-x) lead++;
		if (mark[que[tail]]-mark[que[lead]]==y-x)
		{
			if (mark[que[lead]]>=x)
			{
				cout<<1<<endl;
				cout<<mark[que[lead]]-x<<endl;
				return 0;
			}
			if (mark[que[lead]]+y<=len)
			{
				cout<<1<<endl;
				cout<<mark[que[lead]]+y<<endl;
				return 0;
			}
		}
	}
	cout<<2<<endl;
	cout<<x<<' '<<y<<endl;
	return 0;
}


/*
//如何写一份可以提交的代码？以A+B为例
#include <iostream>
using namespace std;
int main()
{
	int a, b; //定义两个变量名
	cin >> a >> b; //从标准输入流中输入两个整数
	cout << a + b << endl; //输出到标准输出流中
	return 0;
}
// 完成程序以后，点击下方的提交，即可看到测试结果
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,l,x,y,zo,yo,a,b,c,d;
int aa[5100];

int find(int a)
{
	int j=1;
	for (int i=2;i<=n;i++)
	{
		while (aa[i]-aa[j]>a) j++;
		if (aa[i]-aa[j]==a) return j;
	}
	return 0;
}
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++)
    	scanf("%d",&aa[i]);

    a=find(x);
    b=find(y);

    if (a&&b)
    {
        printf("0");
        return 0;
    }
    if (a)
    {
       printf("1\n");
       printf("%d",y);
       return 0;
    }
    if (b)
    {
       printf("1\n");
       printf("%d",x);
       return 0;
    }
    if (x+y<=l)
    c=find(x+y);
    d=find(y-x);
    if (c)
    {
    	printf("1\n");
    	printf("%d",aa[c]+x);
    	return 0;
    }
    if (d)
    {
    	printf("1\n");
    	printf("%d",aa[d]-x);
    	return 0;
    }
    printf("2\n");
    printf("%d %d",x,y);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=101000;
const int mo=100007;
int n,l,x,y,dis[maxn],xx,yy,head[mo+1002],p,yes,ans[10];
struct data
{
	int go,next;
}edge[maxn];
void build(int a,int b)
{
	p++;
	edge[p].go=b;
	edge[p].next=head[a];
	head[a]=p;
}
int can(int mm)
{
	if (mm<0) return 0;
	if (mm>l) return 0;
	return 1;
}
int F(int a,int gg)
{
	for (int i=head[a];i;i=edge[i].next)
	{
		if (edge[i].go==gg) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&dis[i]);
		int kk=dis[i] % mo;
		build(kk,dis[i]);
	}
	yes=0;
 	for (int i=1;i<=n;i++)
 	{
 		if (dis[i]+x<=l&&F((dis[i]+x)%mo,dis[i]+x)) xx++;
 		if (dis[i]-x>=0&&F((dis[i]-x)%mo,dis[i]-x)) xx++;
 		if (dis[i]+y<=l&&F((dis[i]+y)%mo,dis[i]+y)) yy++;
 		if (dis[i]-y>=0&&F((dis[i]-y)%mo,dis[i]-y)) yy++;
 	}
 	if (xx&yy)
 	{
 		printf("0");
 		exit(0);
 	}
 if (xx)
 	{
 		printf("1\n");
 		printf("%d",y);
 		exit(0);
 	}
 	if (yy)
 	{
 		printf("1\n");
 		printf("%d",x);
 		exit(0);
 	}
for (int i=1;i<=n;i++)
	{
		int mm=dis[i]-x;
	 	if (can(mm))
	 	{
	 		if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 	}
		mm=dis[i]+x;
		if (can(mm))
		{
				if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
		}
	 mm=dis[i]-y;
	 if (can(mm))
	 {
	 		if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 }
	mm=dis[i]+y;
	if (can(mm))
	{
			if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	}
	}
	printf("2\n");
	printf("%d %d\n",x,y);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=101000;
const int mo=100007;
int n,l,x,y,dis[maxn],xx,yy,head[mo],p,yes,ans[10];
struct data
{
	int go,next;
}edge[maxn];
void build(int a,int b)
{
	p++;
	edge[p].go=b;
	edge[p].next=head[a];
	head[a]=p;
}
int can(int mm)
{
	if (mm<0) return 0;
	if (mm>l) return 0;
	return 1;
}
int F(int a,int gg)
{
	for (int i=head[a];i;i=edge[i].next)
	{
		if (edge[i].go==gg) return 1;
	}
	return 0;
}
int main()
{
	//freopen("t2.in","r",stdin);
//	freopen("t2.out","w",stdout);
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&dis[i]);
		int kk=dis[i] % mo;
		build(kk,dis[i]);
	}
	yes=0;
 	for (int i=1;i<=n;i++)
 	{
 		if (dis[i]+x<=l&&F((dis[i]+x)%mo,dis[i]+x)) xx++;
 		if (dis[i]-x>=0&&F((dis[i]-x)%mo,dis[i]-x)) xx++;
 		if (dis[i]+y<=l&&F((dis[i]+y)%mo,dis[i]+y)) yy++;
 		if (dis[i]-y>=0&&F((dis[i]-y)%mo,dis[i]-y)) yy++;

 	}
 	if (xx&yy)
 	{
 		printf("0");
 		exit(0);
 	}
 	if (xx)
 	{
 		printf("1\n");
 		printf("%d",y);
 		exit(0);
 	}
 	if (yy)
 	{
 			printf("1\n");
 		printf("%d",x);
 		exit(0);
 	}
/*	for (int i=1;i<=n;i++)
	{
		int mm=dis[i]-x;
	 	if (can(mm))
	 	{
	 		if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 	}
		mm=dis[i]+x;
		if (can(mm))
		{
				if (mm+y<=l&&F((mm+y)%mo,mm+y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-y>=0&&F((mm-y)%mo,mm-y))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
		}
	 mm=dis[i]-y;
	 if (can(mm))
	 {
	 		if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 }
	mm=dis[i]+y;
	if (can(mm))
	{
			if (mm+x<=l&&F((mm+x)%mo,mm+x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	 			if (mm-x>=0&&F((mm-x)%mo,mm-x))
	 		{
	 			printf("1\n");
	 			printf("%d",mm);
	 			exit(0);
	 		}
	}
	} */
	printf("2\n");
	printf("%d %d\n",x,y);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int bj[100010],n,l,x,y;
bool find(int a,int b,int c)
{
	int st=a-1,en=b+1,mid;
	while(st+1 < en)
	{
		mid=(st+en)>>1;
		if(bj[mid]<=c) st=mid;
		else en=mid;
	}
	return bj[st]==c;
}
int main()
{
	scanf("%d%d%d%d",&n,&l,&x,&y);
	for(int i=1;i<=n;i++) scanf("%d",&bj[i]);
	int er=1,one=1;
	for(int i=1;i<=n;i++)
	{
		if(find(i+1,n,bj[i]+y)) er=0;
		if(find(i+1,n,bj[i]+x)) one=0;
	}
	printf("%d\n",er+one);
	if(one) printf("%d ",x+bj[1]);
	if(er) printf("%d ",y+bj[1]);
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#define NN 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;
ll t=0,dm=0;
template <class Z> void Swap(Z &a, Z &b){
    Z temp;
    temp=a;
    a=b;
    b=temp;
}
int str_to_int(string a){
    int z=0,i,len=a.length();
    for (i=0; i<len; i++)
        z=z*10+(a[i]-'0');
    return z;
}
int main(){
    ll n,l,x,y,i,j,a[100000];
    vector<bool> t(NN,false);
    bool M_OK=0,G_OK=0;
    cin>>n>>l>>x>>y;
  /*  for (i=0; i<NN; i++)
        t[i]=false;*/
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        t[a[i]]=1;
    }
    for (i=0; i<n && (!M_OK || !G_OK); i++){
        if (x+a[i]<=l && t[x+a[i]])
            G_OK=1;
        if (y+a[i]<=l && t[y+a[i]])
            M_OK=1;
    }
    if (M_OK && G_OK){
        cout<<0;
        return 0;
    }
    if (!M_OK && G_OK){
        cout<<1<<endl<<y;
        return 0;
    }
    if (M_OK && !G_OK){
        cout<<1<<endl<<x;
        return 0;
    }
    for (i=0; i<n; i++){
        if (a[i]+x+y<=l && t[a[i]+x+y]){
            cout<<1<<endl<<a[i]+x;
            return 0;
        }
        if (a[i]+y-x<=l && t[a[i]+y-x] && (a[i]+y<=l || a[i]-x>=0)){
            if (a[i]+y<=l)
                cout<<1<<endl<<a[i]+y;
            else
                cout<<1<<endl<<a[i]-x;
            return 0;
        }
    }
    cout<<2<<endl<<x<<" "<<y;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#define NN 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;
ll t=0,dm=0;
template <class Z> void Swap(Z &a, Z &b){
    Z temp;
    temp=a;
    a=b;
    b=temp;
}
int str_to_int(string a){
    int z=0,i,len=a.length();
    for (i=0; i<len; i++)
        z=z*10+(a[i]-'0');
    return z;
}
int main(){
    ll n,l,x,y,i,j,a[100000];
    vector<bool> t(NN,false);
    bool M_OK=0,G_OK=0;
    cin>>n>>l>>x>>y;
  /*  for (i=0; i<NN; i++)
        t[i]=false;*/
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        t[a[i]]=1;
    }
    for (i=0; i<n && (!M_OK || !G_OK); i++){
        if (x+a[i]<=l && t[x+a[i]])
            G_OK=1;
        if (y+a[i]<=l && t[y+a[i]])
            M_OK=1;
    }
    if (M_OK && G_OK){
        cout<<0;
        return 0;
    }
    if (!M_OK && G_OK){
        cout<<1<<endl<<y;
        return 0;
    }
    if (M_OK && !G_OK){
        cout<<1<<endl<<x;
        return 0;
    }
    for (i=0; i<n; i++){
        if (a[i]+x+y<=l && t[a[i]+x+y]){
            cout<<1<<endl<<a[i]+x;
            return 0;
        }
        if (a[i]+y-x<=l && t[a[i]+y-x]){
            cout<<1<<endl<<a[i]+y;
            return 0;
        }
    }
    cout<<2<<endl<<x<<" "<<y;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#define NN 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;
ll t=0,dm=0;
template <class Z> void Swap(Z &a, Z &b){
    Z temp;
    temp=a;
    a=b;
    b=temp;
}
int str_to_int(string a){
    int z=0,i,len=a.length();
    for (i=0; i<len; i++)
        z=z*10+(a[i]-'0');
    return z;
}
int main(){
    ll n,l,x,y,i,j,a[100000];
    vector<bool> t(NN,false);
    bool M_OK=0,G_OK=0;
    cin>>n>>l>>x>>y;
  /*  for (i=0; i<NN; i++)
        t[i]=false;*/
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        t[a[i]]=1;
    }
    for (i=0; i<n && (!M_OK || !G_OK); i++){
        if (t[x+a[i]])
            G_OK=1;
        if (t[y+a[i]])
            M_OK=1;
    }
    if (M_OK && G_OK){
        cout<<0;
        return 0;
    }
    if (!M_OK && G_OK){
        cout<<1<<endl<<y;
        return 0;
    }
    if (M_OK && !G_OK){
        cout<<1<<endl<<x;
        return 0;
    }
    for (i=0; i<n; i++)
        if (t[a[i]+x+y]){
            cout<<1<<endl<<a[i]+x;
            return 0;
        }
    cout<<2<<endl<<x<<" "<<y;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#define NN 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;
ll t=0,dm=0;
template <class Z> void Swap(Z &a, Z &b){
    Z temp;
    temp=a;
    a=b;
    b=temp;
}
int str_to_int(string a){
    int z=0,i,len=a.length();
    for (i=0; i<len; i++)
        z=z*10+(a[i]-'0');
    return z;
}
int main(){
    ll n,l,x,y,i,j,a[100000];
    vector<bool> t(NN,false);
    bool M_OK=0,G_OK=0;
    cin>>n>>l>>x>>y;
  /*  for (i=0; i<NN; i++)
        t[i]=false;*/
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        t[a[i]]=1;
    }
    for (i=0; i<n && (!M_OK || !G_OK); i++){
        if (x+a[i]<=l && t[x+a[i]])
            G_OK=1;
        if (y+a[i]<=l && t[y+a[i]])
            M_OK=1;
    }
    if (M_OK && G_OK){
        cout<<0;
        return 0;
    }
    if (!M_OK && G_OK){
        cout<<1<<endl<<y;
        return 0;
    }
    if (M_OK && !G_OK){
        cout<<1<<endl<<x;
        return 0;
    }
    for (i=0; i<n && a[i]+x+y<=l; i++)
        if (t[a[i]+x+y]){
            cout<<1<<endl<<a[i]+x;
            return 0;
        }
    cout<<2<<endl<<x<<" "<<y;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#define NN 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;
ll t=0,dm=0;
template <class Z> void Swap(Z &a, Z &b){
    Z temp;
    temp=a;
    a=b;
    b=temp;
}
int str_to_int(string a){
    int z=0,i,len=a.length();
    for (i=0; i<len; i++)
        z=z*10+(a[i]-'0');
    return z;
}
int main(){
    ll n,l,x,y,i,j,a[100000];
    vector<bool> t(NN,false);
    bool M_OK=0,G_OK=0;
    cin>>n>>l>>x>>y;
  /*  for (i=0; i<NN; i++)
        t[i]=false;*/
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        t[a[i]]=1;
    }
    for (i=0; i<n && (!M_OK || !G_OK); i++){
        if (x+a[i]<=l && t[x+a[i]])
            G_OK=1;
        if (y+a[i]<=l && t[y+a[i]])
            M_OK=1;
    }
    if (M_OK && G_OK){
        cout<<0;
        return 0;
    }
    if (!M_OK && G_OK){
        cout<<1<<endl<<y;
        return 0;
    }
    if (M_OK && !G_OK){
        cout<<1<<endl<<x;
        return 0;
    }
    for (i=0; i<n; i++){
        if (a[i]+x+y<=l && t[a[i]+x+y]){
            cout<<1<<endl<<a[i]+x;
            return 0;
        }
        if (a[i]+y-x<=l && t[a[i]+y-x] && a[i]+y<=l){
            cout<<1<<endl<<a[i]+y;
            return 0;
        }
    }
    cout<<2<<endl<<x<<" "<<y;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#define NN 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;
ll t=0,dm=0;
template <class Z> void Swap(Z &a, Z &b){
    Z temp;
    temp=a;
    a=b;
    b=temp;
}
int str_to_int(string a){
    int z=0,i,len=a.length();
    for (i=0; i<len; i++)
        z=z*10+(a[i]-'0');
    return z;
}
int main(){
    ll n,l,x,y,i,j,a[100000];
    static bool t[NN];
    bool M_OK=0,G_OK=0;
    cin>>n>>l>>x>>y;
  /*  for (i=0; i<NN; i++)
        t[i]=false;*/
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        t[a[i]]=1;
    }
    for (i=0; i<n && (!M_OK || !G_OK); i++){
        if (t[x+a[i]])
            G_OK=1;
        if (t[y+a[i]])
            M_OK=1;
    }
    if (M_OK && G_OK){
        cout<<0;
        return 0;
    }
    if (!M_OK && G_OK){
        cout<<1<<endl<<y;
        return 0;
    }
    if (M_OK && !G_OK){
        cout<<1<<endl<<x;
        return 0;
    }
    for (i=0; i<n; i++)
        if (t[a[i]+x+y]){
            cout<<1<<endl<<a[i]+x;
            return 0;
        }
    cout<<2<<endl<<x<<" "<<y;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)2e5 + 9;
const ll MOD = 998244353;

ll k;

ll mult(ll a, ll b){
    return (a * b) % MOD;
}

void add(ll &a, ll b){
    a = (a + b) % MOD;
}

ll solve(int len, ll ff, ll ss){
    if(k == 2){
        if(ff==-1 && ss==-1)
            return 2;
        if(ff==-1 || ss==-1)
            return 1;
        ff -- ;
        ss -- ;
        ll r = ff ^ (len % 2);
        return r != ss;
    }
    ll dp[len][3];
    memset(dp, 0, sizeof dp);
    if(ff==-1)
        dp[0][0] = 1, dp[0][1] = 1, dp[0][2] = k - 2;
    else
        dp[0][1] = 1, dp[0][2] = k - 2;
    for(int i = 1; i < len ; i ++ ){
        add(dp[i][0], dp[i-1][1]);
        add(dp[i][0], dp[i-1][2]);
        add(dp[i][1], dp[i-1][0]);
        add(dp[i][1], dp[i-1][2]);
        add(dp[i][2], mult(dp[i-1][0],k-2));
        add(dp[i][2], mult(dp[i-1][1],k-2));
        add(dp[i][2], mult(dp[i-1][2],k-3));
    }
    if(ss==-1)
        return dp[len-1][0] + dp[len-1][1] + dp[len-1][2];
    else if(ss == ff)
        return dp[len-1][1] + dp[len-1][2];
    else
        return dp[len-1][0] + dp[len-1][2];
}

ll Calc(vector<ll> nums){

    ll ff = -1;
    ll ss = -1;
    int cnt = 0;
    ll res = 1ll;
    for(auto x : nums){
        if(x == -1){
            cnt ++ ;
        }
        else{
            ss=x;
            if(cnt > 0)res = mult(res, solve(cnt,ff,ss));
            else{
                if(ss==ff){
                    res *= 0;
                }
            }
            ss=-1;
            ff=x;
            cnt=0;
        }
    }
    if(cnt > 0)
        res = mult(res, solve(cnt,ff,ss));
    return res;
}

int main(){
    fastIO;
    int n;
    cin >> n >> k;
    vector<ll> v1, v2;
    ll a;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> a;
        if(i % 2 == 0) v1.push_back(a);
        else v2.push_back(a);
    }
    cout << mult(Calc(v1),Calc(v2));
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
const ll MOD = 998244353;

ll n, k;

ll powr(ll n, ll ki){
    if(ki==0) return 1;
    ll v = powr(n,ki/2);
    v = (v * v) % MOD;
    if(ki % 2 == 1) v = (v * n) % MOD;
    return v;

}

ll vals(ll l, ll r, ll x1, ll x2){
    if(x1==-1){
        return powr(k-1,r-l+1);
    }
    if(r-l+1 == 1){
        if(x1==x2){
            return k-1;
        }
        else{
            return k-2;
        }
    }
    ll vl = powr(r-l, (k-1));
    vl = (vl * (k-2)) % MOD;
    return vl;
}

ll Calc(vector<int> st){
    if(st.empty()) return 1;
    int n = st.size();
    int ls = 0;
    int y = -1;
    int v1, v2;
    ll ans = 1ll;
    for(int i = 0 ; i < n; i ++ ){
        if(st[i] != -1){
            v1 = ls;
            v2 = i - 1;
            if(v1 <= v2){
                ans = (ans * vals(v1,v2,y,st[i])) % MOD;
            }
            ls = i+1;
            y = st[i];
        }
    }
    if(y == -1){
        ans = (ans * k) % MOD;
        ls ++ ;
    }
    while(ls < n){
        ans = (ans * (k-1)) % MOD;
        ls ++ ;
    }
    return ans;
}

int main(){
    fastIO;
    cin >> n >> k;
    vector<int> even, odd;
    ll x;
    for(int i = 0 ; i < n; i ++ ){
        cin >> x;
        if(i%2 == 0)
            even.push_back(x);
        else
            odd.push_back(x);
    }
    cout << Calc(odd) * Calc(even) % MOD << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
const ll MOD = 998244353;

ll n, k;

ll powr(ll n, ll ki){
    if(ki==0) return 1;
    ll v = powr(n,ki/2);
    v = (v * v) % MOD;
    if(ki % 2 == 1) v = (v * n) % MOD;
    return v;

}

ll vals(ll l, ll r, ll x1, ll x2){
    if(x1==-1){
        return powr(k-1,r-l+1);
    }
    ll vl = powr((k-1), r-l);
    vl = (vl * (k-2)) % MOD;
    return vl;
}

ll Calc(vector<int> st){
    for(int i = 1; i < st.size(); i ++ )
        if(st[i] == st[i - 1] && st[i] != -1)
            return 0;
    if(st.empty()) return 1;
    int n = st.size();
    int ls = 0;
    int y = -1;
    int v1, v2;
    ll ans = 1ll;
    for(int i = 0 ; i < n; i ++ ){
        if(st[i] != -1){
            v1 = ls;
            v2 = i - 1;
            if(v1 <= v2){
                ans = (ans * vals(v1,v2,y,st[i])) % MOD;
            }
            ls = i+1;
            y = st[i];
        }
    }
    if(y == -1){
        ans = (ans * k) % MOD;
        ls ++ ;
    }
    while(ls < n){
        ans = (ans * (k-1)) % MOD;
        ls ++ ;
    }
    return ans;
}

int main(){
    fastIO;
    cin >> n >> k;
    vector<int> even, odd;
    ll x;
    for(int i = 0 ; i < n; i ++ ){
        cin >> x;
        if(i%2 == 0)
            even.push_back(x);
        else
            odd.push_back(x);
    }
    cout << Calc(odd) * Calc(even) % MOD << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
const ll MOD = 998244353;

ll n, k;

ll powr(ll n, ll ki){
    if(ki==0) return 1;
    ll v = powr(n,ki/2);
    v = (v * v) % MOD;
    if(ki % 2 == 1) v = (v * n) % MOD;
    return v;

}

ll vals(ll l, ll r, ll x1, ll x2){
    if(x1==-1){
        return powr(k-1,r-l+1);
    }
    ll vl = powr((k-1), r-l);
    vl = (vl * (k-2)) % MOD;
    return vl;
}

ll Calc(vector<int> st){
    if(st.empty()) return 1;
    int n = st.size();
    int ls = 0;
    int y = -1;
    int v1, v2;
    ll ans = 1ll;
    for(int i = 0 ; i < n; i ++ ){
        if(st[i] != -1){
            v1 = ls;
            v2 = i - 1;
            if(v1 <= v2){
                ans = (ans * vals(v1,v2,y,st[i])) % MOD;
            }
            ls = i+1;
            y = st[i];
        }
    }
    if(y == -1){
        ans = (ans * k) % MOD;
        ls ++ ;
    }
    while(ls < n){
        ans = (ans * (k-1)) % MOD;
        ls ++ ;
    }
    return ans;
}

int main(){
    fastIO;
    cin >> n >> k;
    vector<int> even, odd;
    ll x;
    for(int i = 0 ; i < n; i ++ ){
        cin >> x;
        if(i%2 == 0)
            even.push_back(x);
        else
            odd.push_back(x);
    }
    cout << Calc(odd) * Calc(even) % MOD << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
const ll MOD = 998244353;

ll n, k;

ll powr(ll n, ll ki){
    if(ki==0) return 1;
    ll v = powr(n,ki/2);
    v = (v * v) % MOD;
    if(ki % 2 == 1) v = (v * n) % MOD;
    return v;

}

ll vals(ll l, ll r, ll x1, ll x2){
    if(x1==-1){
        return powr(k-1,r-l+1);
    }
    if(r-l+1 == 1){
        if(x1==x2){
            return k-1;
        }
        else{
            return k-2;
        }
    }
    ll vl = powr((k-1), r-l);
    vl = (vl * (k-2)) % MOD;
    return vl;
}

ll Calc(vector<int> st){
    if(st.empty()) return 1;
    int n = st.size();
    int ls = 0;
    int y = -1;
    int v1, v2;
    ll ans = 1ll;
    for(int i = 0 ; i < n; i ++ ){
        if(st[i] != -1){
            v1 = ls;
            v2 = i - 1;
            if(v1 <= v2){
                ans = (ans * vals(v1,v2,y,st[i])) % MOD;
            }
            ls = i+1;
            y = st[i];
        }
    }
    if(y == -1){
        ans = (ans * k) % MOD;
        ls ++ ;
    }
    while(ls < n){
        ans = (ans * (k-1)) % MOD;
        ls ++ ;
    }
    return ans;
}

int main(){
    fastIO;
    cin >> n >> k;
    vector<int> even, odd;
    ll x;
    for(int i = 0 ; i < n; i ++ ){
        cin >> x;
        if(i%2 == 0)
            even.push_back(x);
        else
            odd.push_back(x);
    }
    cout << Calc(odd) * Calc(even) % MOD << "\n";

    return 0;
}


/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include<iostream>
#include<vector>
#define MOD 998244353
using namespace std;
int powr(int a,int b)
{
    int c=1;
    for(int i=1;i<=b;i++)
    {
        c=c*a;
    }
    return c;
}
int main()
{
    int n; cin>>n;
    int k; cin>>k;

    vector<int>a;
    vector<int>b;
    for(int i=0;i<n;i++)
    {
        if(i%2==0) {int x; cin>>x; a.push_back(x);}
        else {int x; cin>>x; b.push_back(x);}
    }
    int cntDiff[n];
    int cntSame[n];
    cntDiff[0]=1;
    cntSame[0]=0;
    for(int i=1;i<n;i++)
    {
        cntSame[i]=((k-1)*cntDiff[i-1])%MOD;
        cntDiff[i]=(cntSame[i-1]+(k-2)*cntDiff[i-1])%MOD;
        cout<<cntSame[i]<<" "<<cntDiff[i]<<" "<<endl;
    }
    int i=0;
    int ans=1;
    int u;
    for(u=0;u<a.size();u++)
    {
        if(a[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        int y=a.size();
        ans=(ans*powr(k-1,y-1)*k)%MOD;
    }
    else
    {
    while(i<a.size())
    {
       if(i==0){
        while(i<a.size() && a[i]==-1)
        {
            ans=(ans*(k-1))%MOD;
            i++;
        }
       }
       if(i>=a.size()) break;
    int save=a[i];
    int j=i+1; int cont=0;
    for(;j<a.size();j++)
    {
      cout<<a[j]<<" ";
        if(a[j]!=-1) {break;}
        cont++;
    }
    cout<<"\na[i]= "<<a[i]<<" a[j]= "<<a[j]<<endl;
    if(j<a.size())
      {
       if(a[j]==a[i])
       {
           ans=(ans*cntSame[cont])%MOD;
       }
       else
       {
           ans=(ans*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans=(ans*powr(k-1,cont))%MOD;
          break;
      }

    }
    }
    cout<<ans<<endl;
   int ans2=1;
   i=0;
    for(u=0;u<a.size();u++)
    {
        if(b[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        int y=b.size();
        ans2=(ans2*powr(k-1,y-1)*k)%MOD;
    }
   else
   {
    while(i<b.size())
    {
       if(i==0){
        while(i<b.size() && b[i]==-1)
        {
            ans2=(ans2*(k-1))%MOD;
            i++;
        }
       }
       if(i>=b.size()) break;
    int save=a[i];
    int j=i+1; int cont=0;
    for(;j<b.size();j++)
    {
        cout<<b[j]<<" ";
        if(b[j]!=-1) {break;}
        cont++;
    }
    cout<<"\nb[i]= "<<b[i]<<" b[j]= "<<b[j]<<endl;
    if(j<b.size())
      {
       if(b[j]==b[i])
       {
           ans2=(ans2*cntSame[cont])%MOD;
       }
       else
       {
           ans2=(ans2*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans2=(ans2*powr(k-1,cont))%MOD;
          break;
      }

    }
   }
    cout<<ans2<<endl;
    cout<<(ans*ans2)%MOD<<endl;
    return 0;
}


/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include<iostream>
#include<vector>
#define MOD 998244353
using namespace std;
int powr(int a,int b)
{
    int c=1;
    for(int i=1;i<=b;i++)
    {
        c=c*a;
    }
    return c;
}
int main()
{
    int n; cin>>n;
    int k; cin>>k;

    vector<int>a;
    vector<int>b;
    for(int i=0;i<n;i++)
    {
        if(i%2==0) {int x; cin>>x; a.push_back(x);}
        else {int x; cin>>x; b.push_back(x);}
    }
    int cntDiff[n];
    int cntSame[n];
    cntDiff[0]=1;
    cntSame[0]=0;
    for(int i=1;i<n;i++)
    {
        cntSame[i]=((k-1)*cntDiff[i-1])%MOD;
        cntDiff[i]=(cntSame[i-1]+(k-2)*cntDiff[i-1])%MOD;
        //cout<<cntSame[i]<<" "<<cntDiff[i]<<" "<<endl;
    }
    int i=0;
    int ans=1;
    int u;
    for(u=0;u<a.size();u++)
    {
        if(a[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        int y=a.size();
        ans=(ans*powr(k-1,y-1)*k)%MOD;
    }
    else
    {
    while(i<a.size())
    {
       if(i==0){
        while(i<a.size() && a[i]==-1)
        {
            ans=(ans*(k-1))%MOD;
            i++;
        }
       }
       if(i>=a.size()) break;
    int save=a[i];
    int j=i+1; int cont=0;
    for(;j<a.size();j++)
    {
     // cout<<a[j]<<" ";
        if(a[j]!=-1) {break;}
        cont++;
    }
 //   cout<<"\na[i]= "<<a[i]<<" a[j]= "<<a[j]<<endl;
    if(j<a.size())
      {
       if(a[j]==a[i])
       {
           ans=(ans*cntSame[cont])%MOD;
       }
       else
       {
           ans=(ans*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans=(ans*powr(k-1,cont))%MOD;
          break;
      }

    }
    }
 //   cout<<ans<<endl;
   int ans2=1;
   i=0;
    for(u=0;u<a.size();u++)
    {
        if(b[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        int y=b.size();
        ans2=(ans2*powr(k-1,y-1)*k)%MOD;
    }
   else
   {
    while(i<b.size())
    {
       if(i==0){
        while(i<b.size() && b[i]==-1)
        {
            ans2=(ans2*(k-1))%MOD;
            i++;
        }
       }
       if(i>=b.size()) break;
    int save=a[i];
    int j=i+1; int cont=0;
    for(;j<b.size();j++)
    {
     //   cout<<b[j]<<" ";
        if(b[j]!=-1) {break;}
        cont++;
    }
    //cout<<"\nb[i]= "<<b[i]<<" b[j]= "<<b[j]<<endl;
    if(j<b.size())
      {
       if(b[j]==b[i])
       {
           ans2=(ans2*cntSame[cont])%MOD;
       }
       else
       {
           ans2=(ans2*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans2=(ans2*powr(k-1,cont))%MOD;
          break;
      }

    }
   }
    //cout<<ans2<<endl;
    cout<<(ans*ans2)%MOD<<endl;
    return 0;
}


/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include<iostream>
#include<vector>
#define MOD 998244353
using namespace std;
long long int powr(long long int a,long long int b)
{
    long long int c=1;
    for(long long int i=1;i<=b;i++)
    {
        c=(c*a)%MOD;
    }
    return c%MOD;
}
int main()
{
    long long int n; cin>>n;
    long long int k; cin>>k;

    vector<long long int>a;
    vector<long long int>b;
    for(long long int i=0;i<n;i++)
    {
        if(i%2==0) {long long int x; cin>>x; a.push_back(x);}
        else {long long int x; cin>>x; b.push_back(x);}
    }
    long long int cntDiff[n];
    long long int cntSame[n];
    cntDiff[0]=1;
    cntSame[0]=0;
    for(long long int i=1;i<n;i++)
    {
        cntSame[i]=(((k-1)%MOD)*(cntDiff[i-1]%MOD))%MOD;
        cntDiff[i]=((cntSame[i-1])%MOD+(((k-2)%MOD*cntDiff[i-1]%MOD)%MOD))%MOD;
     //   cout<<cntSame[i]<<" "<<cntDiff[i]<<" "<<endl;
    }
    long long int i=0;
    long long int ans=1;
    long long int u;
    for(u=0;u<a.size();u++)
    {
        if(a[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        long long int y=a.size();
        ans=(ans*powr(k-1,y-1)*k)%MOD;
    }
    else
    {
    while(i<a.size())
    {
       if(i==0){
        while(i<a.size() && a[i]==-1)
        {
            ans=(ans*(k-1))%MOD;
            i++;
        }
       }
       if(i>=a.size()) break;
    long long int save=a[i];
    long long int j=i+1; long long int cont=0;
    for(;j<a.size();j++)
    {
     // cout<<a[j]<<" ";
        if(a[j]!=-1) {break;}
        cont++;
    }
 //   cout<<"\na[i]= "<<a[i]<<" a[j]= "<<a[j]<<endl;
    if(j<a.size())
      {
       if(a[j]==a[i])
       {
           ans=(ans*cntSame[cont])%MOD;
       }
       else
       {
           ans=(ans*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans=(ans*powr(k-1,cont))%MOD;
          break;
      }

    }
    }
 //   cout<<ans<<endl;
   long long int ans2=1;
   i=0;
    for(u=0;u<a.size();u++)
    {
        if(b[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        long long int y=b.size();
        ans2=(ans2*powr(k-1,y-1)*k)%MOD;
    }
   else
   {
    while(i<b.size())
    {
       if(i==0){
        while(i<b.size() && b[i]==-1)
        {
            ans2=(ans2*(k-1))%MOD;
            i++;
        }
       }
       if(i>=b.size()) break;
    long long int save=a[i];
    long long int j=i+1; long long int cont=0;
    for(;j<b.size();j++)
    {
     //   cout<<b[j]<<" ";
        if(b[j]!=-1) {break;}
        cont++;
    }
    //cout<<"\nb[i]= "<<b[i]<<" b[j]= "<<b[j]<<endl;
    if(j<b.size())
      {
       if(b[j]==b[i])
       {
           ans2=(ans2*cntSame[cont])%MOD;
       }
       else
       {
           ans2=(ans2*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans2=(ans2*powr(k-1,cont))%MOD;
          break;
      }

    }
   }
    //cout<<ans2<<endl;
    cout<<(ans*ans2)%MOD<<endl;
    return 0;
}


/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include<iostream>
#include<vector>
#define MOD 998244353
using namespace std;
int powr(int a,int b)
{
    int c=1;
    for(int i=1;i<=b;i++)
    {
        c=c*a;
    }
    return c;
}
int main()
{
    int n; cin>>n;
    int k; cin>>k;

    vector<int>a;
    vector<int>b;
    for(int i=0;i<n;i++)
    {
        if(i%2==0) {int x; cin>>x; a.push_back(x);}
        else {int x; cin>>x; b.push_back(x);}
    }
    int cntDiff[n];
    int cntSame[n];
    cntDiff[0]=1;
    cntSame[0]=0;
    for(int i=1;i<n;i++)
    {
        cntSame[i]=((k-1)*cntDiff[i-1])%MOD;
        cntDiff[i]=(cntSame[i-1]+(k-2)*cntDiff[i-1])%MOD;
        //cout<<cntSame[i]<<" "<<cntDiff[i]<<" "<<endl;
    }
    int i=0;
    int ans=1;
    int u;
    for(u=0;u<a.size();u++)
    {
        if(a[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        int y=a.size();
        ans=(ans*powr(k-1,y-1)*k)%MOD;
    }
    else
    {
    while(i<a.size())
    {
       if(i==0){
        while(i<a.size() && a[i]==-1)
        {
            ans=(ans*(k-1))%MOD;
            i++;
        }
       }
       if(i>=a.size()) break;
    int save=a[i];
    int j=i+1; int cont=0;
    for(;j<a.size();j++)
    {
      cout<<a[j]<<" ";
        if(a[j]!=-1) {break;}
        cont++;
    }
 //   cout<<"\na[i]= "<<a[i]<<" a[j]= "<<a[j]<<endl;
    if(j<a.size())
      {
       if(a[j]==a[i])
       {
           ans=(ans*cntSame[cont])%MOD;
       }
       else
       {
           ans=(ans*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans=(ans*powr(k-1,cont))%MOD;
          break;
      }

    }
    }
 //   cout<<ans<<endl;
   int ans2=1;
   i=0;
    for(u=0;u<a.size();u++)
    {
        if(b[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        int y=b.size();
        ans2=(ans2*powr(k-1,y-1)*k)%MOD;
    }
   else
   {
    while(i<b.size())
    {
       if(i==0){
        while(i<b.size() && b[i]==-1)
        {
            ans2=(ans2*(k-1))%MOD;
            i++;
        }
       }
       if(i>=b.size()) break;
    int save=a[i];
    int j=i+1; int cont=0;
    for(;j<b.size();j++)
    {
     //   cout<<b[j]<<" ";
        if(b[j]!=-1) {break;}
        cont++;
    }
    //cout<<"\nb[i]= "<<b[i]<<" b[j]= "<<b[j]<<endl;
    if(j<b.size())
      {
       if(b[j]==b[i])
       {
           ans2=(ans2*cntSame[cont])%MOD;
       }
       else
       {
           ans2=(ans2*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans2=(ans2*powr(k-1,cont))%MOD;
          break;
      }

    }
   }
    //cout<<ans2<<endl;
    cout<<(ans*ans2)%MOD<<endl;
    return 0;
}


/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include<iostream>
#include<vector>
#define MOD 998244353
using namespace std;
long long int powr(long long int a,long long int b)
{
    long long int c=1;
    for(long long int i=1;i<=b;i++)
    {
        c=c*a;
    }
    return c;
}
int main()
{
    long long int n; cin>>n;
    long long int k; cin>>k;

    vector<long long int>a;
    vector<long long int>b;
    for(long long int i=0;i<n;i++)
    {
        if(i%2==0) {long long int x; cin>>x; a.push_back(x);}
        else {long long int x; cin>>x; b.push_back(x);}
    }
    long long int cntDiff[n];
    long long int cntSame[n];
    cntDiff[0]=1;
    cntSame[0]=0;
    for(long long int i=1;i<n;i++)
    {
        cntSame[i]=(((k-1)%MOD)*(cntDiff[i-1]%MOD))%MOD;
        cntDiff[i]=((cntSame[i-1])%MOD+(((k-2)%MOD*cntDiff[i-1]%MOD)%MOD))%MOD;
     //   cout<<cntSame[i]<<" "<<cntDiff[i]<<" "<<endl;
    }
    long long int i=0;
    long long int ans=1;
    long long int u;
    for(u=0;u<a.size();u++)
    {
        if(a[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        long long int y=a.size();
        ans=(ans*powr(k-1,y-1)*k)%MOD;
    }
    else
    {
    while(i<a.size())
    {
       if(i==0){
        while(i<a.size() && a[i]==-1)
        {
            ans=(ans*(k-1))%MOD;
            i++;
        }
       }
       if(i>=a.size()) break;
    long long int save=a[i];
    long long int j=i+1; long long int cont=0;
    for(;j<a.size();j++)
    {
     // cout<<a[j]<<" ";
        if(a[j]!=-1) {break;}
        cont++;
    }
 //   cout<<"\na[i]= "<<a[i]<<" a[j]= "<<a[j]<<endl;
    if(j<a.size())
      {
       if(a[j]==a[i])
       {
           ans=(ans*cntSame[cont])%MOD;
       }
       else
       {
           ans=(ans*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans=(ans*powr(k-1,cont))%MOD;
          break;
      }

    }
    }
 //   cout<<ans<<endl;
   long long int ans2=1;
   i=0;
    for(u=0;u<a.size();u++)
    {
        if(b[u]!=-1) break;
    }
    if(u == a.size())
    {
        // all -1's
        long long int y=b.size();
        ans2=(ans2*powr(k-1,y-1)*k)%MOD;
    }
   else
   {
    while(i<b.size())
    {
       if(i==0){
        while(i<b.size() && b[i]==-1)
        {
            ans2=(ans2*(k-1))%MOD;
            i++;
        }
       }
       if(i>=b.size()) break;
    long long int save=a[i];
    long long int j=i+1; long long int cont=0;
    for(;j<b.size();j++)
    {
     //   cout<<b[j]<<" ";
        if(b[j]!=-1) {break;}
        cont++;
    }
    //cout<<"\nb[i]= "<<b[i]<<" b[j]= "<<b[j]<<endl;
    if(j<b.size())
      {
       if(b[j]==b[i])
       {
           ans2=(ans2*cntSame[cont])%MOD;
       }
       else
       {
           ans2=(ans2*cntDiff[cont])%MOD;
       }
       i=j;
      }
      else {
          ans2=(ans2*powr(k-1,cont))%MOD;
          break;
      }

    }
   }
    //cout<<ans2<<endl;
    cout<<(ans*ans2)%MOD<<endl;
    return 0;
}


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
//    db(s);
    return my_pow(k-1,s);
}

ll f2(ll s){
    if(s == 0) return 1;

    ll res = 0;

    res +=    k*my_pow(k-1,s-1);
    res %= MOD;

    res += 2*MOD - 2 * my_pow(k-1, s-1);
    res %= MOD;

    res += (s-2 >= 0 ? my_pow(k-1,s-2) : 0);
    res %= MOD;

    return res;

}

ll solve(vc<ll> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(int x : v) sum += x;

    // all -1
    if(sum == -n) {

        return  (k* my_pow(k-1,n-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

//    db(fn);
//    db(Ln);

    int cnt = 0;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
//            db(cnt);
            res *= f2(cnt);
            res %= MOD;
            cnt=0;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    int n;

//    n = 10, k = 7;
//
//    db(f2(0));
//    db(f2(1));
//    db(f2(2));
//    db(f2(3));
//
//    vc<ll> v = {-1,-1, 2,3, -1,-1,-1,-1, 2,3,4,-1,-1,-1,-1,-1,-1,3,4,5,-1,-1,-1};
//    solve(v);
//    exit(0);

    vc<ll> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
    return my_pow(k-1,s);
}

ll f2(ll s){

    ll res = 0;

    res +=    k*my_pow(k-1,s-1);
    res %= MOD;

    res += 2*MOD - 2 * my_pow(k-1, s-1);
    res %= MOD;

    res += (s-2 >= 0 ? my_pow(k-1,s-2) : 0);
    res %= MOD;

    return res;

}

ll solve(vc<int> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(int x : v) sum += x;

    // all -1
    if(sum == -n) {
        if(n == 1) return k;

        return  (my_pow(k-1,n-1) * k ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

    int cnt = 0;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
            res *= f2(cnt);
            res %= MOD;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    int n;

    vc<int> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
//    db(s);
    return my_pow(k-1,s);
}

ll memof2[N][2];
ll f2(ll s, int same){
//    db(s);
//    db(same);

    if(memof2[s][same] != -1) return memof2[s][same];
    if(s == 0){
        if(same) return 0;
        return 1;
    }

    if(same){
        ll res = f2(s-1, 0)*(k-1);
        res %= MOD;

        return memof2[s][same]=res;
    }

    // not same
    else {
        ll res = 0;

        res += f2(s-1,1);
        res %= MOD;

        res += f2(s-1, 0) * (k-2);
        res %= MOD;

        return memof2[s][same]=res;
    }

}

ll solve(vc<ll> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(ll x : v) sum += x;

    // all -1
    if(sum == -n) {

        return  (k* my_pow(k-1,n-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

//    db(fn);
//    db(Ln);

    int cnt = 0;

    int lastN = fn;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
//            db(cnt);
            int same = v[i] == v[lastN];
            res *= f2(cnt, same);
            res %= MOD;
            cnt=0;

            lastN = i;
        } else {
            cnt++;
        }
    }

//    db(res);

    return res;

}

int main() {
    loop(i,N){
        loop(j,2){
            memof2[i][j] = -1;
        }
    }

    int n;

//
/*
    db(f1(0));
    db(f1(1));
    db(f1(2));
    db(f1(3));

    db(f2(0));
    db(f2(1));
    db(f2(2));
    db(f2(3));
    */
//

    vc<ll> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
//    db(s);
    return my_pow(k-1,s);
}

ll memof2[N][2];
ll f2(ll s, int same){
    if(memof2[s][same] != -1) return memof2[s][same];
    if(s == 0){
        if(same) return 1;
        return 0;
    }

    if(same){
        ll res = f2(s-1, 0)*(k-1);
        res %= MOD;

        return memof2[s][same]=res;
    }

    // not same
    else {
        ll res = 0;

        res += f2(s-1,1);
        res %= MOD;

        res += f2(s-1, 0) * (k-2);
        res %= MOD;

        return memof2[s][same]=res;
    }

}

ll solve(vc<ll> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(ll x : v) sum += x;

    // all -1
    if(sum == -n) {

        return  (k* my_pow(k-1,n-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

//    db(fn);
//    db(Ln);

    int cnt = 0;

    int lastN = fn;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
//            db(cnt);
            int same = v[i] == lastN;
            res *= f2(cnt, same);
            res %= MOD;
            cnt=0;

            lastN = i;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    loop(i,N){
        loop(j,2){
            memof2[i][j] = -1;
        }
    }

    int n;

    n = 10, k = 2;
//
/*
    db(f1(0));
    db(f1(1));
    db(f1(2));
    db(f1(3));

    db(f2(0));
    db(f2(1));
    db(f2(2));
    db(f2(3));
    */
//

    vc<ll> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
    return my_pow(k-1,s);
}

ll f2(ll s){

    ll res = 0;

    res +=    k*my_pow(k-1,s-1);
    res %= MOD;

    res += 2*MOD - 2 * my_pow(k-1, s-1);
    res %= MOD;

    res += (s-2 >= 0 ? my_pow(k-1,s-2) : 0);
    res %= MOD;

    return res;

}

ll solve(vc<int> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(int x : v) sum += x;

    // all -1
    if(sum == -n) {

        return  (k* my_pow(k-1,n-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

    int cnt = 0;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
            res *= f2(cnt);
            res %= MOD;
            cnt=0;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    int n;

    vc<int> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
    return my_pow(k-1,s);
}

ll f2(ll s){

    return
    k*my_pow(k-1,s-1) - 2 * my_pow(k-1, s-1) + (s-2 >= 0 ? my_pow(k-1,s-2) : 0);

}

ll solve(vc<int> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+2 < n; i++){
        if(v[i] != -1 && v[i+2] != -1 && v[i] == v[i+2]) return 0;
    }

    ll sum = 0;
    for(int x : v) sum += x;

    // all -1
    if(sum == -n) {
        if(n == 1) return k;

        return  (my_pow(k,n-1) * (k-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

    int cnt = 0;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
            res *= f2(cnt);
            res %= MOD;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    int n;

    vc<int> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
    return my_pow(k-1,s);
}

ll f2(ll s){

    return
    k*my_pow(k-1,s-1) - 2 * my_pow(k-1, s-1) + (s-2 >= 0 ? my_pow(k-1,s-2) : 0);

}

ll solve(vc<int> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(int x : v) sum += x;

    // all -1
    if(sum == -n) {
        if(n == 1) return k;

        return  (my_pow(k,n-1) * (k-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

    int cnt = 0;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
            res *= f2(cnt);
            res %= MOD;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    int n;

    vc<int> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include<bits/stdc++.h>

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

int DEBUG = 1;
//#define printf(...) (0)
#define db(x) if(DEBUG) cout << #x << " = " << x << endl
#define dbCont(x)if(DEBUG) { cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;};

using namespace std;

const int N = 200 * 1000 + 123;

const int MOD = 998244353 ;

int k;

ll my_pow(ll base, ll exp){
    if(exp == 0) return 1;

    ll h = my_pow(base, exp/2);
    h = (h*h)%MOD;

    if(exp%2 == 1) h = (h*base)%MOD;

    return h;
}
ll f1(ll s){
    return my_pow(k-1,s);
}

ll f2(ll s){

    ll res = 0;

    res +=    k*my_pow(k-1,s-1);
    res %= MOD;

    res += 2*MOD - 2 * my_pow(k-1, s-1);
    res %= MOD;

    res += (s-2 >= 0 ? my_pow(k-1,s-2) : 0);
    res %= MOD;

    return res;

}

ll solve(vc<int> &v){
//    printf("\n\n\n\n");
//    dbCont(v);

    if(v.empty()) return 1;

    int n = v.size();
    // check ok
    for(int i = 0; i+1 < n; i++){
        if(v[i] != -1 && v[i+1] != -1 && v[i] == v[i+1]) return 0;
    }

    ll sum = 0;
    for(int x : v) sum += x;

    // all -1
    if(sum == -n) {
        if(n == 1) return k;

        return  (my_pow(k,n-1) * (k-1) ) % MOD;
    }

    int Ln;
    loop(i,n)  if(v[i] != -1) Ln = i;

    int fn;
    for(int i = n-1; i >= 0; i--) if(v[i] != -1) fn = i;

    ll res = 1;

    res *= f1(fn);
    res %= MOD;

    res *= f1(n-Ln-1);
    res %= MOD;

    int cnt = 0;
    for(int i = fn+1; i <= Ln; i++){
        if(v[i] != -1){
            res *= f2(cnt);
            res %= MOD;
        } else {
            cnt++;
        }
    }

    return res;

}

int main() {
    int n;

    vc<int> odd,even;
    scanf("%d%d",&n,&k);

    loop(i,n){
        int e;
        scanf("%d",&e);
        if(i % 2 == 0) even.push_back(e);
        else odd.push_back(e);
    }

    ll res = solve(even) * solve(odd);
    res %= MOD;

    cout << res << endl;

    return 0;
}

/*
---------------------Test--------------------

*/


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	long long ans = 1;
	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[id].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[i] == b[id]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
		if (i >= 3 && a[i] == a[i - 2] && a[i] != -1) {
			ans = 0;
		}
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1 + MOD) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[id].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[id][i - 1] == b[id][pos]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	long long ans = 1;
	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[id].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[id][i - 1] == b[id][pos]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
		if (i >= 3 && a[i] == a[i - 2] && a[i] != -1) {
			ans = 0;
		}
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1 + MOD) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[id].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[id][i - 1] == b[id][pos]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i] + 1) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	long long ans = 1;
	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			//cout << id << " " << i << " " << pos << endl;
			if (pos == b[id].size() || i == 0) {
				if (pos - i == 1 && b[id].size() > 1) {
					ans = ans * (k - 1) % MOD;
				} else {
					ans = ans * pow_mod(k - 1, pos - i - 1) % MOD * k % MOD;
				}
			} else {
				if (b[i] == b[id]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	long long ans = 1;
	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[i].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[i] == b[id]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	long long ans = 1;
	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i == 1 && b[id].size() == 1) {
					ans = ans * (k) % MOD;
				} else {
					ans = ans * pow_mod(k - 1, pos - i) % MOD % MOD;
				}
			} else {
				if (b[i] == b[id]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
		if (i >= 3 && a[i] == a[i - 2] && a[i] != -1) {
			ans = 0;
		}
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[id].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[id][i - 1] == b[id][pos]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 5;
int const MOD = 998244353;

int n, k;
int a[N];
vector < int > b[2];
long long dp[N];

long long pow_mod(int x, int y) {
	if (y == 0) {
		return 1;
	}

	long long u = pow_mod(x, y/ 2);
	u = u * u % MOD;
	if (y % 2 == 1) {
		u = u * x % MOD;
	}
	return u;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i % 2].push_back(a[i]);
	}

	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] * (k - 1) % MOD;
		if (i % 2 == 1) {
			dp[i] = (dp[i] - 1 + MOD) % MOD;
		} else {
			dp[i] = (dp[i] + 1) % MOD;
		}
	}

	long long ans = 1;
	for (int id = 0; id <= 1; id++) {
		for (int i = 0; i < b[id].size();) {
			if (b[id][i] != -1) {
				i++;
				continue;
			}
			int pos = i;
			while (pos < b[id].size() && b[id][pos] == -1) {
				pos++;
			}

			if (pos == b[id].size() || i == 0) {
				if (pos - i != b[id].size()) {
					ans = ans * pow_mod(k - 1, pos - i) % MOD;
				} else {
					ans = ans * (k) % MOD * pow_mod(k - 1, pos - i - 1) % MOD;
				}
			} else {
				if (b[id][i] == b[id][pos]) {
					if ((pos - i) % 2 == 0) {
						ans = ans * (dp[pos - i] - 1 + MOD) % MOD;
					} else {
						ans = ans * (dp[pos - i]) % MOD;
					}
				} else {
					ans = ans * dp[pos - i] % MOD;
				}
			}
			i = pos;
		}

	}

	cout << ans << endl;

}


#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(b>0 && b<=k)
		sum = (mod + sum - dp[l][0])%mod;
	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(int a, int b, int k, int l){
	long long dp[k+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){
		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];
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	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];
				l = 0;
			}
		}
		if(a[i]==-1){
			l++;
		}
	}
	if(l>0)
		ways = (ways*numOfWays(start, end, k, l))%mod;
	//long long w = numOfWays(-1, 1, 3, 1);
	cout<<ways<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long mod= 998244353;
long long same[100001];
long long diff[100001];

long long cntDiff(long long k, long long l);

long long numOfWays1(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;
}

long long cntSame(long long k, long long l){
	if(l<=0){
		same[0] = 0;
		return 0;
	}

	if(same[l]!=-1)
		return same[l];
	if(l%2==1){
		same[l/2] = cntSame(k, l/2);
		diff[l/2] = cntDiff(k, l/2);
		long long diffsquare = (diff[l/2]*diff[l/2])%mod;
		same[l] = ((same[l/2]*same[l/2])%mod + ((k-1)*diffsquare)%mod )%mod;
	}
	else{
		same[l-1] = cntSame(k, l-1);
		diff[l-1] = cntDiff(k, l-1);
		same[l] = ((k-1)*diff[l-1])%mod;
	}
	return same[l];
}

long long cntDiff(long long k, long long l){
	if(l<=0){
		diff[0] = 1;
		return 1;
	}
	if(diff[l]!=-1)
		return diff[l];
	if(l%2==1){
		diff[l/2] = cntDiff(k, l/2);
		same[l/2] = cntSame(k, l/2);
		long long diffsquare = (diff[l/2]*diff[l/2])%mod;
		diff[l] = (2*((same[l/2]*diff[l/2])%mod)%mod) + ((k-2)*(diffsquare))%mod;
	}
	else{
		same[l-1] = cntSame(k, l-1);
		diff[l-1] = cntDiff(k, l-1);
		diff[l] = (same[l-1] + ((k-2)*(diff[l-1]))%mod)%mod;
	}
	return diff[l];
}

long long numOfWays(long long a, long long b, long long k, long long l){
	if(a==-1 || b==-1){
		if(l==0)
			return 1;
		if(a!=-1 || b!=-1){
			same[l-1] = cntSame(k, l-1);
			diff[l-1] = cntDiff(k, l-1);
			long long ans = (same[l-1] + ((k-1)*diff[l-1])%mod)%mod;
			return ans;
		}
		else{
			long long ans = (k*numOfWays(k, b, k, l-1))%mod;
			return ans;
		}
	}
	if(a==b){
		return cntSame(k, l);
	}
	return cntDiff(k, l);
}

int main(){
	long long int n, k;
	cin>>n>>k;
	memset(same, -1, sizeof(same));
	memset(diff, -1, sizeof(diff));
	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;
				//cout<<" check: "<<ways<<" "<<l<<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;
		//cout<<numOfWays(-1, -1, k, l)<<endl;
	}
	// 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(int a, int b, int k, int l){
	long long dp[k+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;
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(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
// =<==<<
// >>>><=
// >>>>=>
// >>>><=
// >=>><<
// >>>>>>
// >>>>=>