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<bitset>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL MOD = 998244353;

const int SIZE = 4096;
//const int SIZE = 16;
using Bits = bitset<SIZE>;
int N;
Bits X, A[6];
Bits B[SIZE];
char buf[SIZE];

void read(Bits &b) {
    scanf("%s", buf);
    b = Bits(buf);
}

int get_high(const Bits &b) {
    for (int i=SIZE; i--;) if (b.test(i)) return i;
    return -1;
}

void MAIN() {
    scanf("%d", &N);
    read(X);
    REP (i, N) read(A[i]);

    REP (i, N) {
	Bits b = A[i];
	int high = get_high(b);

	while (0 <= high && high < SIZE) {
	    if (B[high].test(high)) {
		b ^= B[high];
		high = get_high(b);
	    } else {
		B[high] = b;
		b <<= 1;
		high++;
	    }
	}
    }

    int z = -1;
    REP (i, SIZE) if (B[i].test(i)) {
	z = i;
	break;
    }

    LL cnt = 0;
    Bits ex;

    for (int i=SIZE-1; i>=z; i--) {
	cnt *= 2;
	if (X.test(i)) {
	    cnt += 1;
	}
	if (cnt >= MOD) cnt -= MOD;

	if (X.test(i) != ex.test(i)) {
	    ex ^= B[z] << (i-z);
	}
    }
//    REP (i, SIZE) cerr << B[i].to_ullong()<< " " << B[i] << endl;
//    cerr << X << endl;
//    cerr << ex << endl;
    bool le = true;
    for (int i=z; i>=0; i--) {
	if (!X.test(i) && ex.test(i)) {
	    le = false;
	    break;
	}
	if (X.test(i) && !ex.test(i)) {
	    break;
	}
    }
    if (le) cnt++;

    cnt %= MOD;
    printf("%lld\n", cnt);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}