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 <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 998244353;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 4010
ll p2[N];

void xo(string &a, string &b){
	int n = min(a.size(), b.size());
	rep(i, n) a[i] = '0'+(a[i]^b[i]);
}

bool le(string &a, string &b){
	int n = min(a.size(), b.size());
	rep(i, n){
		if(a[i]<b[i]) return true;
		if(a[i]>b[i]) return false;
	}
	return true;
}

void ker(vector<string> &s){
	int n = s.size();
	rep(i, n-1){
		while(s[i].size()>0){
			if(s[i].size()<s[i+1].size()) s[i].swap(s[i+1]);
			xo(s[i], s[i+1]);
			int j = 0;
			while(j<s[i].size() &&s[i][j]=='0') j++;
			s[i].erase(0, j);
		}
	}
}

int main(){
	int n;
	string x;
	cin>>n>>x;
	int m = x.size();
	vector<string> s(n);
	rep(i, n) cin>>s[i];
	ker(s);
	string a(s[n-1]), b(m, '0');
	p2[0] = 1;
	rep(i, N-1) p2[i+1] = p2[i]*2%mod;
	ll res = 0;
	int m2 = a.size(), l = m-m2+1;
	rep(i, l){
		b.erase(0, 1); b += '0';
		if(x[i]=='1'){
			res += p2[l-i-1];
			if(b[0]=='0'){
				xo(b, a);
			}
		} else {
			if(b[0]=='1'){
				xo(b, a);
			}
		}
		res %= mod;
	}
	/*cerr<<"debug"<<endl;
	cerr<<a<<endl;
	cerr<<b<<endl;
	cerr<<x<<endl;*/
	string y = x.substr(m-m2);
	if(le(b, y)) res++;
	cout<<res%mod<<endl;
	return 0;
}