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 ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 998244353;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

const int N = 4010;
ll pow2[4020];

vi bxor(const vi& a, const vi& b) {
	vi res(N, 0);
	rep(i, 0, N) res[i] = (a[i] ^ b[i]);
	return res;
}

int fbit(const vi& a) { //fbit(0101) = 3
	rer(i, N, 0) {
		if(a[i] == 1) return i + 1;
	}
	return 0;
}

vi shift(const vi& a, int k) {
	vi res(N, 0);
	int fa = fbit(a);
	assert(fa + k <= N);
	rep(i, 0, fa) {
		res[i + k] = a[i];
	}
	return res;
}

bool is_zero(const vi& a) {
	rep(i, 0, N) {
		if(a[i]) return false;
	}
	return true;
}

vi gcd(const vi& a, const vi& b) {
	if(is_zero(b)) return a;
	vi c = a;
	while(true) {
		int fc = fbit(c), fb = fbit(b);
		if(fc < fb) break;
		int diff = fc - fb;
		c = bxor(c, shift(b, diff));
	}
	return gcd(b, c);
}

vi stobit(const string& str) {
	vector<int> res(N, 0);
	int n = sz(str);
	rep(i, 0, n) {
		res[n - i - 1] = str[i] - '0';
	}
	return res;
}

int M;
vi X;
vi B[10];

void solve() {
	string str;
	cin >> M >> str;
	pow2[0] = 1;
	rep(i, 1, 4010) pow2[i] = pow2[i - 1] * 2 % mod;
	X = stobit(str);
	rep(i, 0, M) {
		cin >> str;
		B[i] = stobit(str);
	}
	vi g = B[0];
	rep(i, 0, M - 1) g = gcd(g, B[i + 1]);
	int a = fbit(X), b = fbit(g);
	vi c(N, 0);
	ll res = 0;
	rep(i, 0, (a - b + 1)) {
		if(X[a - i - 1] == 1) {
			ADD(res, pow2[a - b - i]);
			if(c[a - i - 1] == 0) c = bxor(c, shift(g, (a - b - i)));
		}
		if(X[a - i - 1] == 0 && c[a - i - 1] == 1) {
			c = bxor(c, shift(g, (a - b - i)));
		}
	}
	rer(i, N, 0) {
		if(X[i] == 0 && c[i] == 1) {
			cout << res << "\n";
			return;
		}
		else if(X[i] == 1 && c[i] == 0) {
			cout << (res + 1) % mod << "\n";
			return;
		}
	}
	cout << (res + 1) % mod << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}