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 <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define md 998244353

void show(vi x){
  rep(i,x.size())cout<<x[i];
  cout<<endl;
  cout<<endl;
}

vi mod(const vi& a,const vi& b){
  vi crt=a;
  while(crt.size()>=b.size()){
    vi nxt;
    bool mada=true;
    rep(j,b.size()){
      if(!mada){
        nxt.push_back(crt[j]^b[j]);
      }else{
        if(crt[j]^b[j]){
          nxt.push_back(1); mada=false;
        }
      }
    }
    repl(j,b.size(),crt.size()){
      if(!mada){
        nxt.push_back(crt[j]);
      }else{
        if(crt[j]){
          nxt.push_back(1); mada=false;
        }
      }
    }
    crt=nxt;
  }
  return crt;
}

vi mgcd(vi a,vi b){
  if(b.size()==0) return a;
  else return mgcd(b,mod(a,b));
}

ll N;
vi X;
vi A[6];
ll dp[4001][2];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>N;
  {
    string s;
    cin>>s;
    rep(j,s.size())X.push_back(s[j]-'0');
  }
  rep(i,N){
    string s;
    cin>>s;
    rep(j,s.size())A[i].push_back(s[j]-'0');
  }

  vi g=A[0];
  repl(i,1,N){
    g=mgcd(g,A[i]);
  }

  ll d=g.size();
  ll m=X.size()-d+1;
  dp[0][0]=1;
  rep(i,m)rep(j,2){
    rep(nxt,(j==0?X[i]+1:2)){
      (dp[i+1][!(j==0&&nxt==X[i])]+=dp[i][j])%=md;
    }
  }
  ll res=dp[m][1];

  vi Y;
  rep(i,X.size()){
    if(i<m) Y.push_back(X[i]);
    else Y.push_back(0);
  }

  vi r=mod(Y,g);

  rep(i,r.size()){
    Y[Y.size()-1-i]^=r[r.size()-1-i];
  }

  if(Y<=X) cout<<(res+1)%md<<endl;
  else cout<<res<<endl;

  return 0;
}