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 <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
 
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }






inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

long long pow(long long a, long long n, long long m) {
	if (n == 0) return 1 % m;
	long long t = pow(a, n / 2, m);
	t = mod(t * t, m);
	if (n & 1) t = mod(t * a, m);
	return t;
}

long long inv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	return mod(u, m);
}

struct ModPolynomial : vector<long long> {
	long long MOD = 2;
	ModPolynomial() : vector<long long>(1, 0) { }
	ModPolynomial(long long num) : vector<long long>(1, num) { }
	ModPolynomial(int size, long long num) : vector<long long>(size, num) { }
	ModPolynomial(vector<long long> vec) { (*this) = vec; }

	ModPolynomial& normalize() {
		for (int i = 0; i < (*this).size(); ++i) (*this)[i] = mod((*this)[i], MOD);
		while ((*this).size() > 1 && (*this).back() == 0) (*this).pop_back();
		return (*this);
	}

	inline ModPolynomial operator - () {
		for (int i = 0; i < (*this).size(); ++i) (*this)[i] = (*this)[i] * (-1);
		return (*this).normalize();
	}
	inline const ModPolynomial& operator += (const ModPolynomial &x);
	inline const ModPolynomial& operator -= (const ModPolynomial &x);
	inline const ModPolynomial& operator *= (long long x);
	inline const ModPolynomial& operator *= (const ModPolynomial &x);
	inline const ModPolynomial& operator /= (long long x);
	inline const ModPolynomial& operator /= (const ModPolynomial &x);
	inline const ModPolynomial& operator %= (long long x);
	inline const ModPolynomial& operator %= (const ModPolynomial &x);
};

inline bool operator > (ModPolynomial x, ModPolynomial y) { return x.size() > y.size(); }
inline bool operator < (ModPolynomial x, ModPolynomial y) { return y > x; }
inline bool operator <= (ModPolynomial x, ModPolynomial y) { return !(y < x); }
inline bool operator >= (ModPolynomial x, ModPolynomial y) { return !(x < y); }
inline bool operator != (ModPolynomial x, ModPolynomial y) { return x < y || y < x; }
inline bool operator == (ModPolynomial x, ModPolynomial y) { return !(x < y) && !(y < x); }

ostream &operator << (ostream &os, ModPolynomial x) {
	for (int i = (int)x.size() - 1; i >= 0; --i) {
		if (i != (int)x.size() - 1) os << abs(x[i]); else os << x[i];
		if (i != 0) {
			os << "x"; if (i != 1) os << "^" << i; os << " ";
			if (x[i - 1] < 0) os << "- "; else os << "+ ";
		}
	}
	return os;
}

inline ModPolynomial operator + (ModPolynomial x, ModPolynomial y) {
	x.normalize(); y.normalize();
	while (x.size() > y.size()) y.push_back(0);
	while (y.size() > x.size()) x.push_back(0);
	ModPolynomial z((int)x.size(), 0);
	for (int i = 0; i < (int)x.size(); ++i) z[i] = x[i] + y[i];
	return z.normalize();
}
inline ModPolynomial operator - (ModPolynomial x, ModPolynomial y) {
	y = -y;
	return x + y;
}
inline ModPolynomial operator * (ModPolynomial x, long long a) {
	x.normalize();
	ModPolynomial z((int)x.size(), 0);
	for (int i = 0; i < (int)x.size(); ++i) z[i] = mod(x[i] * a, x.MOD);
	return z.normalize();
}
inline ModPolynomial operator * (ModPolynomial x, ModPolynomial y) {
	x.normalize(); y.normalize();
	ModPolynomial z((int)x.size() + (int)y.size() - 1, 0);
	for (int i = 0; i < (int)x.size(); ++i) for (int j = 0; j < (int)y.size(); ++j) z[i + j] = mod(z[i + j] + x[i] * y[j], z.MOD);
	return z.normalize();
}
pair<ModPolynomial, long long> divmod(ModPolynomial x, long long a) {
	x.normalize();
	for (int i = (int)x.size() - 1; i >= 0; --i) x[i] = mod(x[i] * inv(a, x.MOD), x.MOD);
	return pair<ModPolynomial, long long>(x, 0);
}
ModPolynomial operator / (ModPolynomial x, long long a) {
	x.normalize();
	return divmod(x, a).first;
}
long long operator % (ModPolynomial x, long long a) {
	x.normalize();
	return divmod(x, a).second;
}
pair<ModPolynomial, ModPolynomial> divmod(ModPolynomial x, ModPolynomial y) {
	x.normalize(); y.normalize();
	if (x.size() < y.size()) return make_pair(0, x);
	if (y.size() == 1) return divmod(x, y.back());
	ModPolynomial q((int)x.size() - (int)y.size() + 1, 0);
	for (int i = (int)x.size() - 1; i >= (int)y.size() - 1; --i) {
		long long div = mod(x[i] * inv(y.back(), x.MOD), x.MOD);
		q[i - (int)y.size() + 1] = div;
		for (int j = 0; j < (int)y.size(); ++j) x[i + j - (int)y.size() + 1] = mod(x[i + j - (int)y.size() + 1] - y[j] * div, x.MOD);
	}
	return make_pair(q, x.normalize());
}
ModPolynomial operator / (ModPolynomial x, ModPolynomial y) {
	x.normalize(); y.normalize();
	return divmod(x, y).first;
}
ModPolynomial operator % (ModPolynomial x, ModPolynomial y) {
	x.normalize(); y.normalize();
	return divmod(x, y).second;
}
ModPolynomial pow(ModPolynomial a, long long n) {
	a.normalize();
	ModPolynomial res(1, 1);
	while (n > 0) { if (n & 1) { res = res * a; } a = a * a; n >>= 1; }
	return res;
}
ModPolynomial pow(ModPolynomial a, long long n, ModPolynomial PMOD) {
	a.normalize(); PMOD.normalize();
	ModPolynomial res(1, 1);
	while (n > 0) { if (n & 1) { res = (res * a) % PMOD; } a = (a * a) % PMOD; n >>= 1; }
	return res;
}
ModPolynomial gcd(ModPolynomial x, ModPolynomial y) {
	x.normalize(); y.normalize();
	if (y.size() == 1 && y.back() == 0) return x;
	else return gcd(y, x%y);
}
inline const ModPolynomial& ModPolynomial::operator += (const ModPolynomial &x) { *this = *this + x; return *this; }
inline const ModPolynomial& ModPolynomial::operator -= (const ModPolynomial &x) { *this = *this - x; return *this; }
inline const ModPolynomial& ModPolynomial::operator *= (long long x) { *this = *this * x; return *this; }
inline const ModPolynomial& ModPolynomial::operator *= (const ModPolynomial &x) { *this = *this * x; return *this; }
inline const ModPolynomial& ModPolynomial::operator /= (long long x) { *this = *this / x; return *this; }
inline const ModPolynomial& ModPolynomial::operator /= (const ModPolynomial &x) { *this = *this / x; return *this; }
inline const ModPolynomial& ModPolynomial::operator %= (long long x) { *this = *this % x; return *this; }
inline const ModPolynomial& ModPolynomial::operator %= (const ModPolynomial &x) { *this = *this % x; return *this; }
ModPolynomial generateX() { ModPolynomial X(2, 0); X[1] = 1; return X; }
ModPolynomial EX = generateX();



struct Fp {
	int MOD = 998244353;
	long long val;

	Fp() : val(0) {}
	Fp(long long val_) { this->val = mod(val_, MOD); }
	Fp operator = (long long val_) { this->val = mod(val_, MOD); return *this; }
	inline Fp operator - () { return mod(-val, MOD); }
	inline const Fp& operator += (const Fp &x);
	inline const Fp& operator -= (const Fp &x);
	inline const Fp& operator *= (const Fp &x);
	inline const Fp& operator /= (const Fp &x);
};

inline bool operator > (Fp x, Fp y) { return x.val > y.val; }
inline bool operator < (Fp x, Fp y) { return y > x; }
inline bool operator <= (Fp x, Fp y) { return !(y < x); }
inline bool operator >= (Fp x, Fp y) { return !(x < y); }
inline bool operator == (Fp x, Fp y) { return x.val == y.val; }
inline bool operator != (Fp x, Fp y) { return !(x == y); }

ostream &operator << (ostream &os, Fp x) { return os << x.val; }
istream &operator >> (istream &is, Fp &x) { is >> x; return is; }

inline Fp operator + (Fp x, Fp y) { return mod(x.val + y.val, x.MOD); }
inline Fp operator - (Fp x, Fp y) { return mod(x.val - y.val, x.MOD); }
inline Fp operator * (Fp x, Fp y) { return mod(x.val * y.val, x.MOD); }
inline Fp operator / (Fp x, Fp y) {
	long long a = y.val, b = x.MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	return x * u;
}
inline Fp abs(Fp a) { return a; }
inline Fp fpow(Fp a, long long n) {
	if (n == 0) return Fp(1);
	Fp t = fpow(a, n / 2);
	t = t * t; if (n & 1) t = t * a;
	return t;
}
inline const Fp& Fp::operator += (const Fp &x) { *this = *this + x; return *this; }
inline const Fp& Fp::operator -= (const Fp &x) { *this = *this - x; return *this; }
inline const Fp& Fp::operator *= (const Fp &x) { *this = *this * x; return *this; }
inline const Fp& Fp::operator /= (const Fp &x) { *this = *this / x; return *this; }






int N;
ModPolynomial X;
ModPolynomial A[10];


int main() {
	while (cin >> N) {
		string str;
		cin >> str;
		reverse(str.begin(), str.end());
		X.resize(str.size(), 0);
		for (int i = 0; i < str.size(); ++i) X[i] = (long long)(str[i] - '0');
		//COUT(X);

		ModPolynomial g;
		for (int i = 0; i < N; ++i) {
			cin >> str;
			reverse(str.begin(), str.end());
			A[i].resize(str.size(), 0);
			for (int j = 0; j < str.size(); ++j) A[i][j] = (long long)(str[j] - '0');
			//COUT(A[i]);
		}

		g = A[0];
		for (int i = 1; i < N; ++i) {
			g = gcd(g, A[i]);
		}


		Fp res = 0;
		int d = (int)g.size() - 1;

		ModPolynomial EEX = pow(EX, d);
		ModPolynomial q = X / EEX;
		ModPolynomial r = X % EEX;

		for (int i = (int)q.size() - 1; i >= 0; --i) {
			res *= 2;
			if (q[i] == 1) res += 1;
		}

		ModPolynomial DX = (X - X%g);
		

		bool ok = true;
		for (int i = (int)X.size() - 1; i >= 0; --i) {
			if (DX[i] < X[i]) break;
			else if (DX[i] == X[i]) continue;
			if (DX[i] > X[i]) ok = false;
		}
		if (ok) res += 1;


		/*
		COUT(g);
		COUT(d);
		COUT(X);
		COUT(EEX);
		COUT(q);
		COUT(r);
		COUT(DX);
		COUT(DX % g);
		COUT(ok);
		*/

		cout << res << endl;
	}
}