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>
using namespace std;
using ll=long long;
#define pb push_back
#define all(x) x.begin(), x.end()

int n;

char xs[4010];

using V=bitset<4000>;

const ll mod = 998244353;

ll Pow(ll b, ll e){
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=mod;
		e>>=1; (b*=b)%=mod;
	}
	return ret;
}

bool exi[4010];
V key[4010];
void Input(){
	static char buf[4010];
	scanf("%s", buf);
	int l = strlen(buf);
	V v; for(int i=l-1; 0<=i; --i) v[l-1-i]=(buf[i]=='1');
	int top = l-1;
	for(;;){
		bool zr = 0;
		while(exi[top]){
			v ^= key[top];
			while(!v[top]){
				if(top == 0){
					zr = 1;
					break;
				}
				--top;
			}
			if(zr) break;
		}
		if(zr) break;
		for(;!exi[top];){
			exi[top]=1; key[top]=v;
			if(top == 3999) break;
			++top; v<<=1;
		}
	}
}

int main()
{
	scanf("%d%s", &n, xs);
	for(int i=0; i<n; ++i) Input();
	
	vector<int> tops;
	int xt = strlen(xs);
	for(int i=xt-1; 0<=i; --i) if(exi[i]){
		tops.pb(i);
	}
	ll txc=0;
	
	reverse(xs, xs+xt);
	int p=0, tn=tops.size();
	while(tops[p] != xt-1) ++p;
	V cv;
	bool alive = 1;
	for(int i=xt-1; 0<=i; --i){
		if(xs[i]=='1'){
			if(cv[i]){
				if(p<tn && tops[p]==i){
					(txc += Pow(2, tn-p-1)) %= mod;
				}
			} else if(p<tn && tops[p]==i){
				(txc += Pow(2, tn-p-1)) %= mod;
				cv ^= key[i];
			} else {
				(txc += Pow(2, tn-p)) %= mod;
				alive = 0;
				break;
			}
		} else {
			if(cv[i]){
				if(p<tn && tops[p]==i){
					cv ^= key[i];
				} else {
					alive = 0;
					break;
				}
			}
		}
		if(p<tn && tops[p]==i) ++p;
	}
	if(alive) ++txc;
	printf("%lld\n", txc%mod);
	return 0;
}