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<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

const int N=4000;
bitset<N>x,a[5],g,t,c;
char str[N*2];
inline void read(bitset<N> &bit) {
	scanf("%s",str);
	int n=strlen(str)-1;
	for (int i=0;i<=n;i++)
		bit[i]=str[n-i]-'0';
}
inline int deg(bitset<N> &bit) {
	for (int i=N;i--;) if (bit[i]) return i;
	return 0;
}
int p[N];
int main()
{
	int n=gi()-1,i,k,low;
	const int mod=998244353;
	read(x);read(g);
	for (i=0;i<n;i++) {
		read(t);
		while (1) {
			if (deg(g)<deg(t)) swap(g,t);
			low=deg(t);
			for (k=deg(g);k>=low;k--)
				if (g[k])
					g^=t<<(k-low);
			if (g.none()) { g=t; break; }
		}
	}
	for (i=p[0]=1;i<N;i++) p[i]=(p[i-1]<<1)%mod;
	k=deg(g);
	int ans=0;
	for (i=N-1;i>=k;i--) {
		if (x[i]) (ans+=p[i-k])%=mod;
		if (x[i]!=c[i]) c^=g<<(i-k);
	}
	for (i=k;~i;i--) {
		if (x[i]>c[i]) break;
		else if (x[i]<c[i]) { ans--; break; }
	}
	ans++;
	cout<<ans<<endl;
	return 0;
}