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;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 4010;
const LL mod = 998244353;
int N;
bitset<MC> X;
bitset<MC> A[9],B;
int d[9];
int s[9];

int main(){
	cin >> N;
	cin >> X;
	repp(i,0,N) cin >> A[i];
	repp(i,0,N) repp(j,0,MC) if(A[i][j]) d[i] = j;
	if(N>1){
		repp(i,0,N) s[i] = i;
		auto comp = [&](const int p , const int q){return d[p] > d[q];};
		sort(s,s+N,comp);
		while(d[s[1]] >= 0){
			A[s[0]] = (A[s[0]]^(A[s[1]]<<(d[s[0]]-d[s[1]])));
			while(d[s[0]] >= 0 && !A[s[0]][d[s[0]]]) --d[s[0]];
			sort(s,s+N,comp);
		}
		A[0] = A[s[0]];
		d[0] = d[s[0]];
	}
	int z = 0;
	repp(j,0,MC) if(X[j]) z = j;
	LL ans = 0;
	repm(i,z,d[0]-1) ans = (ans * 2 + X[i]) % mod;
	repm(i,z,d[0]-1) if(B[i]^X[i]) B ^= (A[0]<<(i-d[0]));
	++ans;
	repm(i,d[0]-1,-1){
		if(B[i]^X[i]){
			if(B[i]) ans += mod-1;
			break;
		}
	}
	cout << ans % mod << endl;
	return 0;
}