Problem: There are N non-negative integers written on a blackboard. The i-th integer is A_i.

Takahashi can perform the following two kinds of operations any number of times in any order:

* Select one integer written on the board (let this integer be X). Write 2X on the board, without erasing the selected integer.
* Select two integers, possibly the same, written on the board (let these integers be X and Y). Write X XOR Y (XOR stands for bitwise xor) on the blackboard, without erasing the selected integers.



How many different integers not exceeding X can be written on the blackboard? We will also count the integers that are initially written on the board. Since the answer can be extremely large, find the count modulo 998244353.

Constraints

* 1 \leq N \leq 6
* 1 \leq X < 2^{4000}
* 1 \leq A_i < 2^{4000}(1\leq i\leq N)
* All input values are integers.
* X and A_i(1\leq i\leq N) are given in binary notation, with the most significant digit in each of them being 1.

Input

Input is given from Standard Input in the following format:


N X
A_1
:
A_N


Output

Print the number of different integers not exceeding X that can be written on the blackboard.

Examples

Input

3 111
1111
10111
10010


Output

4


Input

4 100100
1011
1110
110101
1010110


Output

37


Input

4 111001100101001
10111110
1001000110
100000101
11110000011


Output

1843


Input

1 111111111111111111111111111111111111111111111111111111111111111
1


Output

466025955

Solution (in CPP):

Solution:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
	 
using namespace std;
	 
typedef long long LL;
typedef double db;
	 
const int L = 8005;
const int N = 8005;
const int mo = 998244353;
 
bitset<L>a[N],Lim;
int n;
int key[N];
LL mi[L];
 
void getbit(bitset<L> &a){
	char s[L];
	scanf("%s",s+1);
	int len=strlen(s+1);
	fo(i,0,len-1)a[i]=s[len-i]-'0';
}
 
bitset<L> trs(bitset<L> a,bitset<L> b){
	int wa,wb;
	fd(i,4000,0)if (a[i]){wa=i;break;}
	fd(i,4000,0)if (b[i]){wb=i;break;}
	if (wa<wb)swap(a,b),swap(wa,wb);
	while(wb>-1){
	a=a^(b<<(wa-wb));
		bool fd=0;
		fd(i,wa,0)if (a[i]){wa=i;fd=1;break;}
		if (!fd)wa=-1;
		if (wa<wb)swap(a,b),swap(wa,wb);
	}
	return a;
}
	 
int main(){
	mi[0]=1;
	fo(i,1,4000)mi[i]=mi[i-1]*2%mo;
	scanf("%d",&n);
	getbit(Lim);
	fo(i,1,n)getbit(a[i]);
	int n_=0;
	fo(i,1,n){
		fo(j,1,i-1)
		if (a[i][key[j]])a[i]=a[i]^a[j];
		if (a[i].count()==0)continue;
		int w=-1;
		fd(x,4000,0)if (a[i][x]){w=x;break;}
		key[i]=w;
		if (w!=-1){
			key[++n_]=w;
			a[n_]=a[i];
		}
	}
	n=n_;
	int pre=0;
	for(bool pd=1;pd;){
		int pn=n;
		pd=0;
		int w=(pre==0)?n:pre;
		fo(i,1,w)
			fo(j,pre+1,pn)
			if (i!=j){
				bitset<L> now=trs(a[i],a[j]);
				fo(p,1,n)
				if (now[key[p]])now=now^a[p];
				if (now.count()>0){
					a[++n]=now;
					key[n]=0;
					fd(x,4000,0)if (now[x]){key[n]=x;break;}
				}
			}
		pre=pn;
	}
	int keyw=1;
	fo(i,2,n)
	if (key[i]<key[keyw])keyw=i;
	int w=0;
	fd(i,4000,0)
	if (Lim[i]){w=i;break;}
	LL ans=0;
	fd(i,w,key[keyw])
	if (Lim[i])ans=(ans+mi[i-key[keyw]])%mo;
	bitset<L>now;
	fo(i,0,4000)now=0;
	fd(i,w,key[keyw])
	if (Lim[i]!=now[i])now=now^(a[keyw]<<(i-key[keyw]));
	int prefer=1;
	fd(i,key[keyw],0)
	if (Lim[i]!=now[i]){
		if (now[i]>Lim[i])prefer=0;
		break;
	}
	ans=(ans+prefer)%mo;
	printf("%lld\n",ans);
	return 0;
}