#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 6;
const int MAXLEN = 4000;
const int MOD = 998244353;

int n, maxlen;
char s[MAXLEN + 1];
int bound[MAXLEN];
int A[MAXN][MAXLEN];
int B[MAXLEN];
int p2[MAXLEN + 1];

void read(int *x) {
	scanf("%s", s); int len = strlen(s); maxlen = max(maxlen, len);
	REP(i, MAXLEN - len) x[i] = 0; REP(i, len) x[MAXLEN - len + i] = s[i] - '0';
}

void print(int *x) {
	FOR(i, MAXLEN - maxlen, MAXLEN) printf("%d", x[i]); puts("");
}

void gaussjord() {
	int r = 0, c = 0;
	while (r < n&&c < MAXLEN) {
		{ int rr = r; while (rr < n&&A[rr][c] == 0) ++rr; if (rr >= n) { ++c; continue; } if (r != rr) FOR(cc, c, MAXLEN) swap(A[r][cc], A[rr][cc]); }
		FOR(rr, r + 1, n) if (A[rr][c] == 1) FOR(cc, c, MAXLEN) if (A[r][cc]) A[rr][cc] = 1 - A[rr][cc];
		++r, ++c;
	}
	n = r;
	for (--r; r >= 0; --r) {
		c = 0; while (A[r][c] == 0) ++c;
		REP(rr,r) if (A[rr][c] == 1) FOR(cc, c, MAXLEN) if (A[r][cc]) A[rr][cc] = 1 - A[rr][cc];
	}
}

int solve() {
	p2[0] = 1; FORE(i, 1, MAXLEN) p2[i] = (ll)2 * p2[i - 1] % MOD;
	//print(bound); REP(i, n) print(A[i]);
	gaussjord();
	//printf("init:\n"); REP(i, n) print(A[i]);
	while (n >= 2) {
		int pcol = 0; while (A[n - 2][pcol] == 0) ++pcol;
		int col = 0; while (A[n - 1][col] == 0) ++col;
		REP(i, MAXLEN) B[i] = A[n - 1][i];
		while (B[pcol] == 0) {
			REP(i, MAXLEN) B[i] = B[i + 1]; B[MAXLEN - 1] = 0;
			if (B[col] != 0) FOR(i, col, MAXLEN) if (A[n - 1][i] == 1) B[i] = 1 - B[i];
			int ccol = 0; while (B[ccol] == 0) ++ccol; if (A[n - 2][ccol] != 0 && ccol != pcol) FOR(i, ccol, MAXLEN) if (B[i] == 1) A[n - 2][i] = 1 - A[n - 2][i];
		}
		FOR(i, pcol, MAXLEN) if (A[n - 2][i] == 1) B[i] = 1 - B[i];
		bool same = true; REP(i, MAXLEN) if (B[i] != 0) same = false;
		if (same) {
			REP(i, MAXLEN) A[n - 2][i] = A[n - 1][i]; --n;
		}
		else {
			REP(i, MAXLEN) A[n - 2][i] = A[n - 1][i];
			REP(i, MAXLEN) A[n - 1][i] = B[i];
			int ncol = 0; while (A[n - 1][ncol] == 0) ++ncol;
			REP(r, n - 1) if (A[r][ncol] == 1) FOR(c, ncol, MAXLEN) if (A[n - 1][c] == 1) A[r][c] = 1 - A[r][c];
		}
		//if (n == 2) { printf("step:\n"); REP(i, n) print(A[i]); }
		//printf("n=%d\n", n);
	}
	int bcol = 0; while (bound[bcol] == 0) ++bcol;
	int rcol = 0; while (A[0][rcol] == 0) ++rcol;
	if (rcol < bcol) return 1;
	REP(i, MAXLEN) B[i] = 0;
	int ret = 0;
	REPE(i, rcol - bcol) {
		//printf("%d: %d vs %d\n", i, B[bcol + i], bound[bcol + i]);
		int x = B[bcol + i], y = bound[bcol + i];
		if (y == 1) ret = (ret + p2[rcol - bcol - i]) % MOD;
		if (x != y) FOR(j, rcol, MAXLEN) if (A[0][j] != 0) B[bcol + i + j - rcol] = 1 - B[bcol + i + j - rcol];
	}
	bool ok = true; REP(i, MAXLEN) if (B[i] < bound[i]) break; else if (B[i] > bound[i]) { ok = false; break; } if (ok) ret = (ret + 1) % MOD;
	return ret;
}

void run() {
	scanf("%d", &n); maxlen = 0;
	read(bound);
	REP(i, n) read(A[i]);
	int ret = solve();
	printf("%d\n", ret);
}

void stress() {
	while (true) {
		n = 6; maxlen = 4000;
		while (true) { REP(j, maxlen) bound[MAXLEN - maxlen + j] = rand() % 2; bool nonzero = false; REP(j, maxlen) if (bound[MAXLEN - maxlen + j] != 0) nonzero = true; if (nonzero) break; }
		REP(i, n) while (true) { REP(j, maxlen) A[i][MAXLEN - maxlen + j] = rand() % 2; bool nonzero = false; REP(j, maxlen) if (A[i][MAXLEN - maxlen + j] != 0) nonzero = true; if (nonzero) break; }
		solve();
		printf("."); fflush(stdout);
	}
}

int main() {
	run();
	//stress();
	return 0;
}


Measured memory_bytes: 512