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:
//Create Time: 2018-05-06 20:54:33
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
const ll mod=(ll)998244353;
const int N=4096;
typedef bitset<N> oo;
bitset<N> an[11],x,gd;
int clz(oo &a){
    int l=1,r=a.size(),mid,ans=0;
    while(l<=r){
        mid=(l+r)>>1;
        if((a>>(N-mid)).none()){
            ans=mid;
            l=mid+1;
        } else r=mid-1;
    }
    return ans;
}
oo gcd(oo a,oo b){
    oo *x=&a,*y=&b;
    int dx=N-clz(*x),dy=N-clz(*y);
    if(dx<dy){
        swap(dx,dy);
        swap(x,y);
    }
    if(y->none())return *y;
    oo res=gcd((*x)^((*y)<<(dx-dy)),*y);
    if(res.none())return *y;
    return res;
}
bool operator<=(const oo &a, const oo &b){
    int l=1,r=a.size(),mid,ans=0;
    while(l<=r){
        mid=(l+r)>>1;
        if((a>>(N-mid))==(b>>(N-mid))){
            ans=mid;
            l=mid+1;
        }else r=mid-1;
    }
    if(ans==a.size())return 1;
    return a[N-ans-1]<=b[N-ans-1];
}
oo divide(oo a,oo b){
    int da,db;
    while(1){
        da=N-clz(a);
        db=N-clz(b);
        if(da<db)break;
        a^=b<<(da-db);
    }
    return a;
}
int main(){
    // freopen("F.in","r",stdin);
    // freopen("F.out","w",stdout);
    int n;cin>>n;
    string s;cin>>s;
    x=bitset<N>(s);
    rep(i,0,n){
        cin>>s;an[i]=bitset<N>(s);
    }
    gd=an[0];
    rep(i,1,n){
        gd=gcd(gd,an[i]);
    }
    // per(i,SZ(gd),0)printf("%d\n",gd[i]?1:0);
    int d=N-clz(gd),m=N-clz(x);
    string sx=x.to_string();
    reverse(all(sx));
    ll ans=0;
    per(i,m,d-1){ 
        if(sx[i]=='1'){
            ans+=powmod(2,i-d+1,mod);
        }
    }
    oo yu=divide(x,gd),tmp=x^yu;
    assert(divide(tmp,gd).none());
    if(tmp<=x)ans++;
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}