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 << 19;
int MOD = 1000000007;
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

const int MX = 4005;
const int MM = 998244353;

typedef bitset<MX> Integer;
void print(Integer P);

bool divide(Integer X, Integer Y, Integer &P, Integer &Q)
{
	Integer Z = X;
	P.reset();
	int high = MX-1;
	for(; high >= 0; high--) if(Y[high]) break;
	for(int i = MX-high-1; i >= 0; i--){
		if( X[i+high] ){
			X ^= Y<<i;
		}
		if( Z[i+high] ){
			Z[i+high] = 0;
			P[i] = 1;
		}
	}
	Q = X;
	print(Z);
	print(Q);
	for(int i = high-1; i >= 0; i--) if( Q[i] ) return Z[i];
	return true;
}

char buf[MX];

Integer gcd(Integer A, Integer B){
	Integer C, D;
	divide(A, B, C, D);
	if( D.none() ) return B;
	else return gcd(B, D);
}

Integer input(){
	Integer X; X.reset();
	scanf("%s", buf);
	int L = strlen(buf);
	for(int i = 0; buf[i]; i++) X[L-i-1] = buf[i]-'0';
	return X;
}

void print(Integer P){
//	for(int i = 0; i < 10; i++) printf("%d", !!P[i]); printf("\n");
}

int main()
{
	int N;
	Integer X, A[10];
	X.reset();
	scanf("%d", &N);
	X = input();
	for(int i = 1; i <= N; i++){
		A[i] = input();
		print(A[i]);
	}

	Integer G = A[1];
	for(int i = 2; i <= N; i++) G = gcd(G, A[i]);
	print(G);

	Integer tmp, t2;
	int ans = 0, flag = 0;
	flag = divide(X, G, tmp, t2);
	for(int i = MX-1; i >= 0; i--){
		ans = (ans * 2 + tmp[i]) % MM;
	}
	printf("%d\n", (ans+flag)%MM);
}