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<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bits bitset<N>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=4005,mod=998244353;
int pw[N],n,m,l,ans;
bits a[N],x,g,now;
char st[N];

bits gcd(bits a,bits b){
	int la=N-1,lb=N-1;
	while(la>=0&&lb>=0){
		while(la>=0&&!a[la]) la--;
		while(lb>=0&&!b[lb]) lb--;
		if(la<0||lb<0) break;
		if(la<lb) b^=a<<(lb-la);
		else a^=b<<(la-lb);
	}
	return la<0?b:a;
}

int main(){
	pw[0]=1;
	rep(i,1,N-1) pw[i]=2*pw[i-1]%mod;
	scanf("%d%s",&n,st),m=strlen(st);
	REP(i,m) if(st[i]=='1') x.set(m-1-i);
	rep(i,1,n){
		scanf("%s",st),m=strlen(st);
		REP(j,m) if(st[j]=='1') a[i].set(m-1-j);
	}
	g=a[1];
	rep(i,2,n) g=gcd(g,a[i]);
	l=N-1;
	while(!g[l]) l--;
	per(i,N-1,l)
		if(x[i]){
			if(!now[i]) now^=g<<(i-l);
			ans=(ans+pw[i-l])%mod;
		}
		else{
			if(now[i]) now^=g<<(i-l);
		}
	int flag=0;
	per(i,l,0){
		if(now[i]==x[i]) continue;
		if(now[i]&&!x[i]) flag=1;
		break;
	}
	if(!flag) ans=(ans+1)%mod;
	cout<<ans<<endl;
	return 0;
}