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<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct F_2 {
	vector<int>  s;
	F_2(string t) {
		s.resize(t.length());
		rep(i, t.length()) {
			if (t[i] == '1')s[i] = 1;
			else s[i] = 0;
		}
	}
	F_2(int c) {
		s = { c };
	}
};
bool operator!=(const F_2 &a, const F_2 &b) {
	return a.s != b.s;
}
bool operator<=(const F_2 &a, const F_2 &b) {
	if (a.s.size() != b.s.size()) {
		return a.s.size() < b.s.size();
	}
	return a.s <= b.s;
}
F_2 operator-(const F_2 &a, const F_2 &b) {
	//assert(a.s.size()>=b.s.size())
	int len = b.s.size();
	F_2 ret = a;
	rep(i, len) {
		if (b.s[i]) {
			ret.s[i] ^= 1;
		}
	}
	rep(i, ret.s.size()) {
		if (ret.s[i] || i == (int)ret.s.size() - 1) {
			ret.s.erase(ret.s.begin(), ret.s.begin() + i);
			break;
		}
	}
	return ret;
}
F_2 operator+(const F_2 &a, const F_2 &b) {
	int l1 = a.s.size(), l2 = b.s.size();
	int len = max(a.s.size(), b.s.size());
	F_2 ret(0); ret.s.resize(len);
	rep(i, len) {
		int c = 0;
		if (i < l1&&a.s[l1 - 1 - i])c ^= 1;
		if (i < l2&&b.s[l2 - 1 - i])c ^= 1;
		ret.s[len - 1 - i] = c;
	}
	rep(i, ret.s.size()) {
		if (ret.s[i] || i == (int)ret.s.size() - 1) {
			ret.s.erase(ret.s.begin(), ret.s.begin() + i);
			break;
		}
	}
	return ret;
}
F_2 operator%(const F_2 &a, const F_2 &b) {
	F_2 ret = a;
	int len = b.s.size();
	while (ret.s.size() >= len&&ret!=0) {
		rep(i, len) {
			if(b.s[i])ret.s[i] ^= 1;
		}
		rep(i, ret.s.size()) {
			if (ret.s[i] || i == (int)ret.s.size() - 1) {
				ret.s.erase(ret.s.begin(), ret.s.begin() + i);
				break;
			}
		}
	}
	return ret;
}

F_2 gcd(F_2 a, F_2 b) {
	if (a.s.size() < b.s.size())swap(a, b);
	while (b!=0) {
		F_2 r = a % b; a = b; b = r;
		/*rep(i, b.s.size()) {
			cout << b.s[i];
		}
		cout << endl;*/
	}
	return a;
}

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
void solve() {
	int n; string x; cin >> n >> x;
	F_2 s(x);
	F_2 g("0");
	rep(i, n) {
		string s; cin >> s;
		F_2 f(s);
		g = gcd(g, s);
	}
	ll ans = 0;
	F_2 cur("0");
	int dif = (int)s.s.size() - (int)g.s.size();
	if (dif < 0) {
		cout << 1 << endl; return;
	}
	for (int d = dif; d >= 0; d--) {
		int z = 0;
		if (cur.s.size() >= g.s.size() + d) {
			int len = cur.s.size();
			int id = len - (int)g.s.size() - d;
			if (cur.s[id])z = 1;
		}
		int l = s.s[dif - d];
		if (l == 1 && z == 1) {
			ans += mod_pow(2, d);
			if (ans >= mod)ans -= mod;
		}
		else if (l == 1 && z == 0) {
			ans += mod_pow(2, d);
			if (ans >= mod)ans -= mod;

			F_2 u = g;
			rep(i, d)u.s.push_back(0);
			cur = cur + u;
		}
		else if (l == 0 && z == 0) {
			continue;
		}
		else {
			F_2 u = g;
			rep(i, d)u.s.push_back(0);
			cur = cur + u;
		}

	}
	if (cur <= s)ans++;
	cout << ans % mod << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}