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 <stdio.h>
#include <algorithm>
#include <bitset>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

typedef long long ll;
const int M = 4020;
typedef bitset<M> bit;

int n;
string xs;
string as[10];

const ll MOD = 998244353ll;
ll bin[5252];

int deg(bit a){
	int ret = -1;
	REP(i,M)if(a[i])ret=i;
	return ret;
}

int main(){
	cin>>n;
	cin>>xs;
	REP(i,n)cin>>as[i];

	bin[0] = 1;
	REP(i,5251)bin[i+1] = bin[i]*2ll%MOD;
	
	bit g = bit(as[0]);
	REP(i,n){
		bit a = bit(as[i]);
		while(true){
			int gdeg = deg(g);
			int adeg = deg(a);
			if(adeg == -1){
				break;
			}else if(gdeg == -1){
				g = a;
				break;
			}else if(adeg == gdeg){
				a = a ^ g;
			}else if(adeg < gdeg){
				g = g ^ (a << (gdeg - adeg));
			}else if(adeg > gdeg){
				a = a ^ (g << (adeg - gdeg));
			}
		}
	}

	ll ans = 0;
	int gdeg = deg(g);
	bit x = bit(xs);
	int xdeg = deg(x);
	if(gdeg > xdeg){
		puts("1");
		return 0;
	}
	string s = xs.substr(0,xdeg-gdeg+1);
	REP(i,s.size()){
		ans = ans * 2ll % MOD;
		ans = (ans + (s[i]-'0')) % MOD;
	}
	bit y = bit(0);
	REP(_i,xdeg-gdeg+1){
		int i = xdeg-gdeg-_i;
		bit z = y ^ (g << i);
		if(deg(z^x) < deg(y^x)){
			y = z;
		}
	}
	bool less = false;
	if(gdeg==0)less = true;
	REP(_i,gdeg){
		int i = gdeg-1-_i;
		if(y[i]==1 && x[i]==0){
			break;
		}else if(y[i]==0 && x[i]==1){
			less = true;
			break;
		}else{
			if(i==0)less = true;
		}
	}
	if(less){
		ans = (ans + 1) % MOD;
	}
	printf("%lld\n", ans);

	return 0;
}