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 For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 7,Len = 4000 + 10,mod = 998244353;

char str[Len];
typedef bitset <Len> Bs;
bool X[Len],A[N][Len],Gcd[Len],cur[Len],Mul[Len];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void Getstr(bool S[]) {
	scanf("%s",str);
	int len = strlen(str);
	reverse(str,str + len);
	For(i,0,len - 1) S[i] = str[i] - '0';
}

inline int Length(bool a[]) {
	Fordown(i,Len - 1,0) if(a[i]) return i;
	return 0;
}

inline void Plus(bool a[],bool b[],int Delta) {
	For(i,Delta,Len - 1) a[i] = a[i] ^ b[i - Delta];
}

inline void gcd(bool a[],bool b[],bool c[]) {
	int Lena = Length(a),Lenb = Length(b);
	if(Lena < Lenb) swap(a,b),swap(Lena,Lenb);
	if(Lenb == 0 && b[0] == 0) { For(i,0,Len - 1) c[i] = a[i]; return; }
	Plus(a,b,Lena - Lenb);
	gcd(b,a,c);
}

int main() {
	int n = read();Getstr(X);
	For(i,1,n) Getstr(A[i]);
	For(i,1,n) {
		For(j,0,Length(Gcd)) cur[j] = Gcd[j];
		gcd(A[i],cur,Gcd);
	}
	int ans = 0,LenG = Length(Gcd);
	Fordown(i,Length(X),LenG) ans = ((ans << 1) + X[i]) % mod;
	Fordown(i,Length(X),LenG) if(Mul[i] ^ X[i]) Plus(Mul,Gcd,i - LenG);

	Fordown(i,LenG - 1,0) {
		if(Mul[i] < X[i]) break;
		if(Mul[i] > X[i]) { ans--;break; }
	}

	printf("%d\n",ans + 1);

	return 0;
}