#include<bits/stdc++.h>
using namespace std;
#define lsk 998244353
bitset<4005> c,d,GCD;
int C[4005];
int n;
int F(bitset<4005> A){
	for(int i=4000;i;--i)if(A[i])return i;return 0;
}
void gcd(){
	while(1){
		if(F(c)>F(GCD))swap(c,GCD);
		int cc=F(c),GG=F(GCD);
		for(int i=GG;i>=cc;--i){
			if(GCD[i])GCD^=(c<<(i-cc));
		}
		if(GCD.none()){swap(c,GCD);break;}
	}
}
int main(){
	C[0]=1;
	for(int i=1;i<=4000;++i)C[i]=(C[i-1]<<1)%lsk;
	scanf("%d",&n);
	cin>>d;cin>>GCD;
	for(int i=2;i<=n;++i)cin>>c,gcd();
	int res=0,G=F(GCD);
	c.reset();
	for(int i=4000;i>=G;--i){
		if(d[i])res=(res+C[i-G])%lsk;
		if(d[i]!=c[i])c^=GCD<<(i-G);
	}
	int F=0;
	for(int i=G;~i;--i)if(d[i]>c[i])break;else if(d[i]<c[i])F=1;
	if(!F)res++;
	cout<<res;
}