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 <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 6;
const int MAXLEN = 4000;
const int MOD = 998244353;

int n, maxlen;
char s[MAXLEN + 1];
int bound[MAXLEN];
int A[MAXN][MAXLEN];
int B[MAXLEN];
int p2[MAXLEN + 1];

void read(int *x) {
	scanf("%s", s); int len = strlen(s); maxlen = max(maxlen, len);
	REP(i, MAXLEN - len) x[i] = 0; REP(i, len) x[MAXLEN - len + i] = s[i] - '0';
}

void print(int *x) {
	FOR(i, MAXLEN - maxlen, MAXLEN) printf("%d", x[i]); puts("");
}

void gaussjord() {
	int r = 0, c = 0;
	while (r < n&&c < MAXLEN) {
		{ int rr = r; while (rr < n&&A[rr][c] == 0) ++rr; if (rr >= n) { ++c; continue; } if (r != rr) FOR(cc, c, MAXLEN) swap(A[r][cc], A[rr][cc]); }
		FOR(rr, r + 1, n) if (A[rr][c] == 1) FOR(cc, c, MAXLEN) if (A[r][cc]) A[rr][cc] = 1 - A[rr][cc];
		++r, ++c;
	}
	n = r;
	for (--r; r >= 0; --r) {
		c = 0; while (A[r][c] == 0) ++c;
		REP(rr,r) if (A[rr][c] == 1) FOR(cc, c, MAXLEN) if (A[r][cc]) A[rr][cc] = 1 - A[rr][cc];
	}
}

int solve() {
	p2[0] = 1; FORE(i, 1, MAXLEN) p2[i] = (ll)2 * p2[i - 1] % MOD;
	//print(bound); REP(i, n) print(A[i]);
	gaussjord();
	//printf("init:\n"); REP(i, n) print(A[i]);
	while (n >= 2) {
		int pcol = 0; while (A[n - 2][pcol] == 0) ++pcol;
		int col = 0; while (A[n - 1][col] == 0) ++col;
		REP(i, MAXLEN) B[i] = A[n - 1][i];
		while (B[pcol] == 0) {
			REP(i, MAXLEN) B[i] = B[i + 1]; B[MAXLEN - 1] = 0;
			if (B[col] != 0) FOR(i, col, MAXLEN) if (A[n - 1][i] == 1) B[i] = 1 - B[i];
			int ccol = 0; while (B[ccol] == 0) ++ccol; if (A[n - 2][ccol] != 0 && ccol != pcol) FOR(i, ccol, MAXLEN) if (B[i] == 1) A[n - 2][i] = 1 - A[n - 2][i];
		}
		FOR(i, pcol, MAXLEN) if (A[n - 2][i] == 1) B[i] = 1 - B[i];
		bool same = true; REP(i, MAXLEN) if (B[i] != 0) same = false;
		if (same) {
			REP(i, MAXLEN) A[n - 2][i] = A[n - 1][i]; --n;
		}
		else {
			REP(i, MAXLEN) A[n - 2][i] = A[n - 1][i];
			REP(i, MAXLEN) A[n - 1][i] = B[i];
			int ncol = 0; while (A[n - 1][ncol] == 0) ++ncol;
			REP(r, n - 1) if (A[r][ncol] == 1) FOR(c, ncol, MAXLEN) if (A[n - 1][c] == 1) A[r][c] = 1 - A[r][c];
		}
		//if (n == 2) { printf("step:\n"); REP(i, n) print(A[i]); }
		//printf("n=%d\n", n);
	}
	int bcol = 0; while (bound[bcol] == 0) ++bcol;
	int rcol = 0; while (A[0][rcol] == 0) ++rcol;
	if (rcol < bcol) return 1;
	REP(i, MAXLEN) B[i] = 0;
	int ret = 0;
	REPE(i, rcol - bcol) {
		//printf("%d: %d vs %d\n", i, B[bcol + i], bound[bcol + i]);
		int x = B[bcol + i], y = bound[bcol + i];
		if (y == 1) ret = (ret + p2[rcol - bcol - i]) % MOD;
		if (x != y) FOR(j, rcol, MAXLEN) if (A[0][j] != 0) B[bcol + i + j - rcol] = 1 - B[bcol + i + j - rcol];
	}
	bool ok = true; REP(i, MAXLEN) if (B[i] < bound[i]) break; else if (B[i] > bound[i]) { ok = false; break; } if (ok) ret = (ret + 1) % MOD;
	return ret;
}

void run() {
	scanf("%d", &n); maxlen = 0;
	read(bound);
	REP(i, n) read(A[i]);
	int ret = solve();
	printf("%d\n", ret);
}

void stress() {
	while (true) {
		n = 6; maxlen = 4000;
		while (true) { REP(j, maxlen) bound[MAXLEN - maxlen + j] = rand() % 2; bool nonzero = false; REP(j, maxlen) if (bound[MAXLEN - maxlen + j] != 0) nonzero = true; if (nonzero) break; }
		REP(i, n) while (true) { REP(j, maxlen) A[i][MAXLEN - maxlen + j] = rand() % 2; bool nonzero = false; REP(j, maxlen) if (A[i][MAXLEN - maxlen + j] != 0) nonzero = true; if (nonzero) break; }
		solve();
		printf("."); fflush(stdout);
	}
}

int main() {
	run();
	//stress();
	return 0;
}