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<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int p = 998244353;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
const int m = 4010;
#define bs bitset<m>
int kai_size = 400001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
vel rui(m + 10, 1);
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}
int max_true(bs &a,int jou) {
	int ans = jou;
	rep(i, jou) {
		if (a[i]) { ans = i; }
	}
	return ans;
}
bool can_div(bs &a, bs b, int &sza, int szb) {
	for (int i = sza; i >= szb; i--) {
		if (a[i]) {
			a ^= b << (i - szb);
		}
	}
	sza = max_true(a, szb);
	if (sza == szb) { return true; }
	return false;
}
bs gcd(bs a, bs b) {
	int sza = max_true(a,m);
	int szb = max_true(b,m);
	if (sza < szb) { swap(sza, szb); swap(a, b); }
	while (true) {
		if (can_div(a, b, sza, szb)) { return b; }
		if (can_div(b, a, szb, sza)) { return a; }
	}
}
void solve(bs &x, bs &a) {
	int szx = max_true(x,m);
	int sza = max_true(a,m);
	bs to;
	rep(i, m) { to[i] = 0; }
	int ans = 0;
	for (int i = szx; i >= sza; i--) {
		if (x[i]) {
			ans += rui[i - sza];
		}
		if (x[i] != to[i]) {
			to ^= a << (i - sza);
		}
	}
	ans++;
	for (int i = m - 1; i >= 0;i--) {
		if (to[i] and !x[i]) { ans--; break; }
		if (x[i] and !to[i]) { break; }
	}
	cout << ans % p << endl;
}
bs mak(string s) {
	rev(s);
	bs ans;
	rep(i, m) { ans[i] = 0; }
	rep(i, s.size()) {
		ans[i] = (s[i] == '1');
	}
	return ans;
}
signed main() {
	int n; cin >> n;
	string x; cin >> x;
	string s; cin >> s;
	bs gcd0 = mak(s);
	rep(i, n - 1) {
		string ne; cin >> ne;
		bs newb = mak(ne);
		gcd0 = gcd(newb, gcd0);
	}
	bs nw = mak(x);
	rep(i, m + 9) { rui[i + 1] = rui[i] * 2; rui[i + 1] %= p; }
	solve(nw, gcd0);
	return 0;
}