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 <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 16;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <int> in[8];
bool dchk[26];

char u[4050];
vector<int> readvec() {
	scanf("%s", u);
	vector <int> rv;
	for (int i = 0; u[i] != 0; i++) rv.push_back(u[i] - '0');
	reverse(all(rv));
	return rv;
}

bool cmp(vector<int> &a, vector<int> &b) {
	if (a.size() != b.size()) return a.size() < b.size();
	for (int i = a.size() - 1; i >= 0; i--) if (a[i] != b[i]) return a[i] < b[i];
	return false;
}
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 0; i <= N; i++) in[i] = readvec();
	

	while(1) {
		int c = 0;
		int mx = 7;
		for (j = 1; j <= N; j++) {
			if (dchk[j]) continue;
			c++;
			if (cmp(in[mx], in[j])) mx = j;
		}
		if (c == 1) {
			swap(in[1], in[mx]);
			break;
		}
		int t;
		for (j = 1; j <= N; j++) {
			if (dchk[j] || j == mx) continue;
			t = j;
		}

		int L1 = in[mx].size(), L2 = in[t].size();
		for (i = 0; i < L2; i++) in[mx][i + L1 - L2] ^= in[t][i];
		while (!in[mx].empty() && !in[mx].back()) in[mx].pop_back();
		if (in[mx].empty()) {
			dchk[mx] = true;
			continue;
		}
		for (i = 1; i <= N; i++) {
			if (dchk[i] || i == mx) continue;
			if (in[i] == in[mx]) dchk[mx] = true;
		}
	}
	
	ll ans = 0;
	int L1 = in[0].size(), L2 = in[1].size();
	for (i = L1 - 1; i >= L2 - 1; i--) ans = (ans * 2 + in[0][i]) % MOD;
	
	in[2].resize(L1);
	for (i = 0; i < L1; i++) in[2][i] = 0;
	for (i = L1 - 1; i >= L2 - 1; i--) {
		if (in[0][i] != in[2][i]) {
			int t = i - (L2 - 1);
			for (j = L2 - 1; j >= 0; j--) in[2][t + j] ^= in[1][j];
		}
	}
	
	bool chk = true;
	for (i = L2 - 2; i >= 0; i--) {
		if (in[0][i] == in[2][i]) continue;
		if (in[0][i] < in[2][i]) chk = false;
		break;
	}
	if (chk) ans = (ans + 1) % MOD;
	return !printf("%lld\n", ans);
}