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;
const int N = 5010, mod = 998244353;
vector<int> nm[N], s, g, t;

int add(int x, int y) {
  return (x += y) >= mod ? x - mod : x;
}

int mul(int x, int y) {
  return 1ll * x * y % mod;
}

vector<int> gcd(vector<int> a, vector<int> b) {
  if(a.size() < b.size()) swap(a, b);
  if(!b.size()) return a;
/*  puts("WWWW");
  for(int i = 0; i < a.size(); ++i)
    printf("%d", a[i]);
  puts("");
  for(int i = 0; i < b.size(); ++i)
    printf("%d", b[i]);
  puts("");*/
  int l = a.size() - b.size();
  vector<int> d(a.size());
  for(int i = 0; i < b.size(); ++i)
    d[i + l] = a[i + l] ^ b[i];
  for(int i = 0; i < l; ++i) d[i] = a[i];
  while(d.size() && !d[d.size() - 1]) {
    d.pop_back();
  }
/*  for(int i = 0; i < d.size(); ++i)
    printf("%d", d[i]);
  puts("\nd!");*/
//  assert(0);
  return gcd(b, d);
}

char lx[N];

void solve() {
  if(g.size() > s.size()) {
    puts("1");
    return ;
  }  
  t = s;
  int l = s.size() - g.size() + 1;
  int ls = s.size(), lg = g.size();
  int ans = 0;
  for(int i = ls - 1; i >= lg - 1; --i) {
    ans = add(mul(ans, 2), s[i]);
  }
  ans = add(ans, 1);
//  printf("%d\n", ans);
  for(int i = 0; i < g.size() - 1; ++i) t[i] = 0;
//  puts("XX");
  for(int i = ls - 1; i >= lg - 1; --i) {
    if(t[i]) {
      for(int j = 0; j < g.size(); ++j) {
        t[i - j] ^= g[g.size() - j - 1];
      }
    }
  }
//  puts("WWW");
  for(int i = g.size() - 2; i >= 0; --i)
    if(t[i] > s[i]) {
      ans = add(ans, mod - 1);
      break;
    } else if(t[i] < s[i]) {
      break;
    }
  printf("%d\n", ans);
}

// s[0] * x ^ 0 + s[1] * x ^ 1 + s[2] * x ^ 2 + .. +

int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", lx + 1);
  int len = strlen(lx + 1);
  for(int i = len; i >= 1; --i) {
    s.push_back(lx[i] - '0');
  }
  for(int i = 1; i <= n; ++i) {
    scanf("%s", lx + 1);
    len = strlen(lx + 1);
    for(int j = len; j >= 1; --j) {
      nm[i].push_back(lx[j] - '0');
    }
  }
  g = nm[1];
  for(int i = 2; i <= n; ++i)
    g = gcd(g, nm[i]);
/*  for(int i = 0; i < g.size(); ++i)
    printf("%d", g[i]);
  puts("\nggg");*/
  solve(); 
  return 0;
}