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 pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const ll MOD = 998244353;

bool cmp(vi& a, vi& b) {
	if (a.size() > b.size()) return 0;
	if (a.size() < b.size()) return 1;
	int n = a.size();
	rep(i, n) {
		if (a[n-1-i]==b[n-1-i]) continue;
		if (a[n-1-i] > b[n-1-i]) return 0;
		else return 1;
	}
	return 0;
}

vi gcd(vi a, vi b) {
	if (cmp(a, b)) {
		swap(a, b);
	}

	bool zero = true;
	for (auto x : b) {
		if (x != 0) zero = false;
	}
	if (zero) return a;

	int d = a.size() - b.size();
	vi res = a;
	rep(i, b.size()) {
		res[i + d] ^= b[i];
	}

	while (res.size() && res.back() == 0) {
		res.pop_back();
	}
	return gcd(res, b);
}

vi get(string s) {
	reverse(ALL(s));
	vi res;
	for (char c : s) {
		res.pb(c - '0');
	}
	return res;
}

int main() {
	int N; cin >> N;
	string sx; cin >> sx;
	vi x = get(sx);
	vi g;

	rep(i, N) {
		string s; cin >> s;
		vi vec = get(s);
		g = gcd(g, vec);
	}

	int dg = g.size(), dx = x.size();

	if (dg > dx) {
		puts("1");
		return 0;
	}

	ll ans = 0;
	for (int i = dx-1; i >= dg-1; --i) {
		ans = ans * 2 + x[i];
		ans %= MOD;
	}

	vi xx(dx);

	for (int i = dx-1; i >= dg-1; --i) {
		if (xx[i] != x[i]) {
			for (int j = 0; j < dg; ++j) {
				xx[i-j] ^= g[dg-1-j];
			}
		}
	}

	bool ok = true;

	for (int j = dg-1; j >= 0; --j) {
		if (x[j] == xx[j]) {
			continue;
		} else if (x[j] > xx[j]) {
			ok = true;
			break;
		} else {
			ok = false;
			break;
		}
	}

	if (ok) { ans = (ans + 1) % MOD; }

	cout << ans << endl;

	return 0;
}