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;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 998244353;

const int MAXN = 4e3 + 5;

deque<int> mn, cur;
deque<int> x;

deque<int> ss;

char c[MAXN];

deque<int> read() {
	scanf("%s", &c[0]);
	deque<int> ans;
	for(int i = 0; c[i]; i++) {
		ans.push_front(c[i] - '0');
	}
	return ans;
}

void set_min(deque<int> &a, deque<int> &b) {
	while(1) {
		if (SZ(a) > SZ(b)) {
			swap(a, b);
		}
		REP(i, 0, SZ(a)) {
			b[SZ(b) - SZ(a) + i] ^= a[i];
		}
		while(SZ(b) > 0 && b[SZ(b) - 1] == 0) {
			b.pop_back();
		}
		if (SZ(b) == 0) {
			return;
		}
	}
	
}

void solve(){
	int n;
	scanf("%d", &n);
	x = read();
	mn = read();
	REP(i, 0, n - 1) {
		cur = read();
		set_min(mn, cur);
	}
	
	if (SZ(mn) > SZ(x)) {
		cout << 0 << endl;
		return;
	}
	
	ll ans = 0ll;
	for(int i = SZ(x) - 1; i >= SZ(mn) - 1; i--) {
		ans = (ans * 2) % MOD;
		if (x[i] == 1) {
			ans = (ans + 1) % MOD;
		}
	}
	
	ss = mn;
	while(SZ(ss) < SZ(x)) {
		ss.push_front(0);
	}
	for(int i = SZ(ss) - 1; i >= SZ(mn) - 1; i--) {
		if (ss[i] != x[i]) {
			REP(j, 0, SZ(mn)) {
				ss[i - SZ(mn) + 1 + j] ^= mn[j];
			}
		}
	}
	
	int fl = 1;
	for(int i = SZ(mn) - 2; i >= 0; i--) {
		if (ss[i] != x[i]) {
			if (ss[i] > x[i]) {
				fl = 0;
			}
			break;
		}
	}
	
	/*for(int i = SZ(mn) - 1; i >= 0; i--) {
		printf("%d", mn[i]);
	}
	printf(" %d\n", fl);*/
	
	ans = (ans + fl) % MOD;
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}