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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int>>
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long>>
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 998244353;
const int SIZE = 1e6+10;
bitset<4000>X,d[4000];
bitset<4000>A[6];
int len[6],Xn;
char s[SIZE];
int N;
void read(bitset<4000>&input,int& l){
    RS(s);
    l=LEN(s);
    input=bitset<4000>(s);
}
int mi_len=0,mi_id=0;
void add(bitset<4000>a,int l){
    for(int j=l;j>=mi_len;j--){
        if(a[j])a^=d[j];
    }
    if(a.none())return;
    for(int j=mi_len-1;j>=0;j--){
        if(a[j]){
            for(int i=mi_len-1;i>=j;i--){
                d[i]=a<<(i-j);
            }
            int original_len=mi_len;
            mi_len=j;
            add(a<<(original_len-j),original_len);
            return;
        }
    }
}
int main(){
    RI(N);
    read(X,Xn);
    REP(i,N)read(A[i],len[i]);
    mi_len=4000;
    REP(i,N){
        if(mi_len>len[i]){
            mi_len=len[i];
            mi_id=i;
        }
    }
    mi_len--;
    for(int i=3999;i>=mi_len;i--){
        d[i]=A[mi_id]<<(i-mi_len);
    }
    REP(i,N){
        if(i==mi_len)continue;
        add(A[i],len[i]-1);
    }
    bitset<4000>fin=X;
    LL an=0;
    for(int i=Xn-1;i>=mi_len;i--){
        //for(int j=i;j>=0;j--)printf("%d",(int)d[i][j]);
        //puts("");
        an*=2;
        if(X[i])an++;
        an%=MOD;
        if(fin[i])fin^=d[i];
    }
    bool suc=1;
    for(int i=mi_len-1;i>=0;i--){
        if(fin[i]){
            if(!X[i]){
                suc=0;
            }
            break;
        }
    }
    if(suc)an++;
    printf("%lld\n",an%MOD);
    return 0;
}