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 <cstdio>
#include <bitset>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int N=4000;
const int mod=998244353;
int n,m,len,a[9][N+1],f[N+1][N+1],s[N+1],ans;
bool ex[N+1];
void inc(int d){
	ans=(ans+s[d])%mod;
}
int main(){
	s[0]=1;
	ref(i,1,N)s[i]=s[i-1]*2%mod;
	scanf("%d",&n);
	ref(i,0,n){
		char c=getchar();while(c<'0'||c>'1')c=getchar();
		m=-1;
		while(c>='0'&&c<='1')a[i][++m]=c-48,c=getchar();
		ref(j,0,m/2)swap(a[i][j],a[i][m-j]);
		while(m>=0&&!a[i][m])m--;
		if(!i){len=m;continue;}
		while(m>=0&&m<=N){
			while(m>=0&&ex[m]){
				ref(j,0,m)a[i][j]^=f[m][j];
				while(m>=0&&!a[i][m])m--;
			}
			if(m<0)break;
			ref(j,0,m)f[m][j]=a[i][j];ex[m]=1;
			def(j,m,0)a[i][j+1]=a[i][j];a[i][0]=0;m++;
		}
	}
	m=N+1;
	while(m>0&&ex[m-1])m--;
	if(m>N){printf("0\n");return 0;}
	def(i,len,m){
		if(a[0][i]==1)inc(i-m);
		if(a[8][i]!=a[0][i])ref(j,0,i)a[8][j]^=f[i][j];
	}
	bool flag=1;
	def(i,m-1,0)if(a[8][i]>a[0][i]){flag=0;break;}
		else if(a[8][i]<a[0][i])break;
	if(flag)inc(0);
	printf("%d\n",ans);
}