Cirno gave AquaMoon a chessboard of size $1 \times n$. Its cells are numbered with integers from $1$ to $n$ from left to right. In the beginning, some of the cells are occupied with at most one pawn, and other cells are unoccupied.

In each operation, AquaMoon can choose a cell $i$ with a pawn, and do either of the following (if possible):

Move pawn from it to the $(i+2)$-th cell, if $i+2 \leq n$ and the $(i+1)$-th cell is occupied and the $(i+2)$-th cell is unoccupied.

Move pawn from it to the $(i-2)$-th cell, if $i-2 \geq 1$ and the $(i-1)$-th cell is occupied and the $(i-2)$-th cell is unoccupied.

You are given an initial state of the chessboard. AquaMoon wants to count the number of states reachable from the initial state with some sequence of operations. But she is not good at programming. Can you help her? As the answer can be large find it modulo $998\,244\,353$.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10000$) — the number of test cases.

The first line contains a single integer $n$ ($1 \leq n \leq 10^5$) — the size of the chessboard.

The second line contains a string of $n$ characters, consists of characters "0" and "1". If the $i$-th character is "1", the $i$-th cell is initially occupied; otherwise, the $i$-th cell is initially unoccupied.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.


-----Output-----

For each test case, print the number of states that reachable from the initial state with some sequence of operations modulo $998\,244\,353$.


-----Examples-----

Input
6
4
0110
6
011011
5
01010
20
10001111110110111000
20
00110110100110111101
20
11101111011000100010
Output
3
6
1
1287
1287
715


-----Note-----

In the first test case the strings "1100", "0110" and "0011" are reachable from the initial state with some sequence of operations.

Difficulty: HARD
Tags: Combinatorics

Mathematics

Starter code:

Solutions:
import sys
import math
input = sys.stdin.readline
h = {}

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
T = int(input())
for _ in range(T):
	n = int(input())
	s = input().rstrip()
	prev = 'x'
	cnt_zero = 0
	cnt_group = 0
	for t in s:
		if t == '0':
			cnt_zero += 1
			prev = t
		elif prev == '1':
			cnt_group += 1
			prev = 'x'
		else:
			prev = t
	answer = ncr(cnt_zero + cnt_group, cnt_zero, 998244353)
	print(answer)


def comb(n, k, MOD):
	if k > n // 2:
		k = n - k
	answer = 1
	for i in range(k):
		answer *= n - i
		answer //= i + 1
	return answer % MOD

def putin():
	return map(int, input().split())

def sol():
	n = int(input())
	A = list(input())
	num_zeros = 0
	num_pairs = 0
	first = 0
	for i in range(n):
		if A[i] == '0':
			first = 0
			num_zeros += 1
		elif first == 0:
			first = 1
		else:
			num_pairs += 1
			first = 0
	print(comb(num_zeros + num_pairs, num_zeros, 998244353))
for itr in range(int(input())):
	sol()


def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
for _ in range(int(input())):
	n = int(input())
	str = input()
	d = str.count('11')
	x = str.count('0')
	print(ncr(d + x, d, 998244353))


import sys
input = sys.stdin.readline
t = int(input())
mod = 998244353
l = 114514
fact = [1] * (l + 1)
for i in range(1, l + 1):
	fact[i] = i * fact[i - 1] % mod
inv = [1] * (l + 1)
inv[l] = pow(fact[l], mod - 2, mod)
for i in range(l - 1, -1, -1):
	inv[i] = (i + 1) * inv[i + 1] % mod

def comb(n, r):
	return fact[n] * inv[r] * inv[n - r] % mod if n >= r >= 0 else 0
for _ in range(t):
	n = int(input())
	s = list(input().rstrip())
	(now, cnt) = (int(s[0]), 0)
	(m, r) = (0, 0)
	for i in s:
		if int(i) == now:
			cnt += 1
		else:
			if now == 0:
				m += cnt
				r += cnt
			else:
				m += cnt // 2
			now ^= 1
			cnt = 1
	if now == 0:
		m += cnt
		r += cnt
	else:
		m += cnt // 2
	ans = comb(m, r)
	print(ans)


from functools import lru_cache
MOD = 998244353
f = [1, 1]

@lru_cache()
def factorial(x):
	l = len(f)
	while l <= x:
		f.append(f[l - 1] * l % MOD)
		l += 1
	return f[x]

def solve():
	n = int(input())
	s = input()
	p = 0
	block = 0
	for ch in s + '0':
		if ch == '1':
			block += 1
		else:
			p += block // 2
			block = 0
	z = s.count('0')
	(pf, zf) = (factorial(p), factorial(z))
	print(factorial(p + z) * pow(pf, -1, MOD) % MOD * pow(zf, -1, MOD) % MOD)

def main():
	t = int(input())
	for __ in range(t):
		solve()
main()


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Combination:

	def __init__(self, n_max, mod=10 ** 9 + 7):
		self.mod = mod
		f = 1
		self.fac = fac = [f]
		for i in range(1, n_max + 1):
			f = f * i % mod
			fac.append(f)
		f = pow(f, mod - 2, mod)
		self.facinv = facinv = [f]
		for i in range(n_max, 0, -1):
			f = f * i % mod
			facinv.append(f)
		facinv.reverse()

	def __call__(self, n, r):
		return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

	def C(self, n, r):
		if not 0 <= r <= n:
			return 0
		return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

	def P(self, n, r):
		if not 0 <= r <= n:
			return 0
		return self.fac[n] * self.facinv[n - r] % self.mod

	def H(self, n, r):
		if n == 0 and r > 0 or r < 0:
			return 0
		return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod
from itertools import groupby
mod = 998244353
comb = Combination(101010, mod)
T = int(input())
for _ in range(T):
	N = int(input())
	S = input()
	r = 0
	n_zeros = S.count('0')
	for (val, gr) in groupby(S):
		gr = list(gr)
		if val == '1':
			if len(gr) % 2 == 1:
				r += 1
	ans = comb.C((N - r + n_zeros) // 2, n_zeros)
	print(ans)


import sys
input = sys.stdin.readline
p = 998244353

def get_facts(n):
	facts = [1] * (n + 1)
	for i in range(1, n + 1):
		facts[i] = facts[i - 1] * i % p
	return facts
for _ in range(int(input())):
	n = int(input())
	facts = get_facts(n)
	group = False
	zero_count = 0
	odd_count = 0
	cur_count = 0
	for c in input():
		if c == '0':
			zero_count += 1
			if group:
				odd_count += cur_count % 2
				group = False
				cur_count = 0
		elif c == '1':
			if group:
				cur_count += 1
			else:
				group = True
				cur_count = 1
	even_count = (n - odd_count - zero_count) // 2
	print(facts[even_count + zero_count] * pow(facts[zero_count], -1, p) * pow(facts[even_count], -1, p) % p)


def powerMod(a, b, MOD):
	if b == 0:
		return 1
	c = powerMod(a, b // 2, MOD)
	c_squared = c * c % MOD
	if b % 2 == 1:
		return c_squared * a % MOD
	else:
		return c_squared
t = int(input())
MOD = 998244353
for d in range(t):
	n = int(input())
	s = input()
	i = 0
	zeroes = 0
	pairs_of_ones = 0
	while i < n:
		if s[i] == '0':
			zeroes += 1
			i += 1
		elif i + 1 < n and s[i + 1] == '1':
			pairs_of_ones += 1
			i += 2
		else:
			i += 1
	result = 1
	for j in range(zeroes + 1, zeroes + pairs_of_ones + 1):
		result = result * j % MOD
	for j in range(2, pairs_of_ones + 1):
		result = result * powerMod(j, MOD - 2, MOD) % MOD
	print(result)


from sys import stdout
from math import comb as c

def solve():
	n = int(input())
	a = list(map(int, input()))
	pair = 0
	zeros = 0
	cur = 0
	for i in range(n):
		if a[i] == 1:
			cur += 1
		else:
			pair += cur // 2
			zeros += 1
			cur = 0
	pair += cur // 2
	print(c(pair + zeros, zeros) % 998244353)
	stdout.flush()

def main():
	for _ in range(int(input())):
		solve()
main()


def ncr(n, r, p):
	(num, den) = (1, 1)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
p = 998244353
t = int(input())
for i in range(t):
	n = int(input())
	zoz = input()
	z = zoz.count('0')
	k = 0
	j = 1
	while j < n:
		if zoz[j] == '1' and zoz[j - 1] == '1':
			k += 1
			j += 2
		else:
			j += 1
	print(ncr(z + k, z, p))


import sys
input = sys.stdin.readline
MX = 10 ** 5 + 10
MOD_NUM = 998244353
F = [-1] * MX
F[0] = F[1] = 1
for x in range(2, MX):
	F[x] = x * F[x - 1]
	F[x] %= MOD_NUM

def choose(a, b):
	return F[a] * pow(F[b], MOD_NUM - 2, MOD_NUM) * pow(F[a - b], MOD_NUM - 2, MOD_NUM) % MOD_NUM
for _ in range(int(input())):
	n = int(input())
	s = input().strip()
	k = 0
	i = 0
	while i < n:
		if s[i] == '0':
			i += 1
			continue
		if i + 1 < n and s[i + 1] == '1':
			k += 1
			i += 1
		i += 1
	z = s.count('0')
	print(choose(z + k, z))


from sys import stdin, stdout
import heapq
from collections import defaultdict
import math
import bisect
import io, os

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def main():
	t = int(stdin.readline())
	MOD = 998244353
	for _ in range(t):
		n = int(stdin.readline())
		s = stdin.readline().strip()
		z = 0
		b = 0
		i = 0
		while i < n:
			if s[i] == '0':
				z += 1
				i += 1
				continue
			elif i + 1 < n and s[i] == s[i + 1] == '1':
				b += 1
				i += 2
				continue
			i += 1
		ans = ncr(z + b, z, MOD)
		stdout.write(str(ans) + '\n')
main()


MOD = 998244353
f = [1, 1]

def factorial(x):
	l = len(f)
	while l <= x:
		f.append(f[l - 1] * l % MOD)
		l += 1
	return f[x]
t = int(input())
for __ in range(t):
	n = int(input())
	s = input()
	p = sum((len(block) // 2 for block in s.split('0')))
	z = s.count('0')
	print(factorial(p + z) * pow(factorial(p), -1, MOD) % MOD * pow(factorial(z), -1, MOD) % MOD)


mod = 998244353

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
for _ in range(int(input())):
	n = int(input())
	chess_board = input()
	count_0 = 0
	count_11 = 0
	cnt = 0
	for square in chess_board:
		if square == '0':
			count_11 += cnt // 2
			count_0 += 1
			cnt = 0
		else:
			cnt += 1
	count_11 += cnt // 2
	number_of_gaps = count_0 + 1
	ans = ncr(count_11 + number_of_gaps - 1, number_of_gaps - 1, mod)
	print(ans)


from math import comb
from sys import stdout

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (r - i) % p
	return num * pow(den, p - 2, p) % p
for t in range(int(input())):
	n = int(input())
	a = input()
	i = 0
	oc = a.count('11')
	zc = a.count('0')
	print(ncr(oc + zc, min(oc, zc), 998244353))
	stdout.flush()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

def so():
	return int(input())

def st():
	return input()

def mj():
	return map(int, input().strip().split(' '))

def msj():
	return map(str, input().strip().split(' '))

def le():
	return list(map(int, input().split()))

def lebe():
	return list(map(int, input()))

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()

def joro(L):
	return ''.join(map(str, L))

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def tir(a, b, c):
	if 0 == c:
		return 1
	if len(a) <= b:
		return 0
	if c != -1:
		return tir(a, 1 + b, c + a[b]) or tir(a, b + 1, c - a[b]) or tir(a, 1 + b, c)
	else:
		return tir(a, 1 + b, a[b]) or tir(a, b + 1, -a[b]) or tir(a, 1 + b, -1)

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def tr(n):
	return n * (n + 1) // 2
boi = 998244353
yr = boi - 2
d = []
p = int(10 + 100000.0)
for i in range(p):
	d.append(-1)
d[0] = 1
d[1] = 1
for i in range(2, p, 1):
	d[i] = d[i - 1] * i
	d[i] = d[i] % boi

def iu():
	import sys
	input = sys.stdin.readline
	import math as my
	m = so()
	t = st()
	op = t.count('0')
	(z, i) = (0, 0)
	while m > i:
		if t[i] == '0':
			i = 1 + i
			continue
		if m - i > 1 and t[1 + i] == '1':
			z = 1 + z
			i = 1 + i
		i = 1 + i
	bec = d[op + z] * pow(d[op], yr, boi) * pow(d[z], yr, boi) % boi
	print(bec)

def main():
	for i in range(so()):
		iu()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from functools import reduce
MOD = 998244353

def perm(n, k):
	return reduce(lambda x, y: x * y % MOD, range(n - k + 1, n + 1), 1)
t = int(input())
for __ in range(t):
	n = int(input())
	s = input()
	p = sum((len(block) // 2 for block in s.split('0')))
	z = s.count('0')
	print(perm(z + p, p) * pow(perm(p, p), -1, MOD) % MOD)


MOD = 998244353
N = 100000
fact = [0] * (N + 1)
fact[0] = 1
fact[1] = 1
for i in range(2, N + 1):
	fact[i] = i * fact[i - 1] % MOD
T = int(input())

def ncr(n, r):
	num = fact[n]
	den = fact[r] * fact[n - r] % MOD
	den = pow(den, MOD - 2, MOD)
	res = num * den % MOD
	return res

def solve():
	n = int(input())
	s = input()
	a = 0
	zeros = 0
	i = 0
	while i < n:
		if s[i] == '1' and i + 1 < n and (s[i + 1] == '1'):
			a += 1
			i += 1
		elif s[i] == '0':
			zeros += 1
		i += 1
	res = ncr(a + zeros, zeros)
	print(res)
while T:
	solve()
	T -= 1


mod = 998244353
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	nmax = 10 ** 5 + 10
	fac = [0] * nmax
	finv = [0] * nmax
	inv = [0] * nmax
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i in range(2, nmax):
		fac[i] = fac[i - 1] * i % mod
		inv[i] = mod - inv[mod % i] * (mod // i) % mod
		finv[i] = finv[i - 1] * inv[i] % mod

	def comb(n, r):
		if n < r:
			return 0
		else:
			return fac[n] * (finv[r] * finv[n - r] % mod) % mod
	for _ in range(int(input())):
		N = int(input())
		S = input().rstrip('\n')
		x = y = 0
		cnt = 0
		prev = '!'
		for (i, s) in enumerate(S):
			if s == '1':
				cnt += 1
			else:
				y += 1
				if prev == '1':
					x += cnt // 2
				cnt = 0
			prev = s
		x += cnt // 2
		print(comb(x + y, x))
main()


MOD = 998244353
f = [1, 1]

def factorial(x):
	l = len(f)
	while l <= x:
		f.append(f[l - 1] * l % MOD)
		l += 1
	return f[x]
T = int(input())
k = [1]
for i in range(T):
	n = int(input())
	arr = input()
	h = dict()
	p = [0]
	r = 0
	s = 0
	r = arr.count('11')
	s = arr.count('0')
	k = [1]
	(pf, zf) = (factorial(r), factorial(s))
	print(factorial(r + s) * pow(pf, -1, MOD) % MOD * pow(zf, -1, MOD) % MOD)


N = 100005
fac = [1] * N
inv = [1] * N
MOD = 998244353
for i in range(1, N):
	fac[i] = fac[i - 1] * i % MOD
inv[-1] = pow(fac[-1], -1, mod=MOD)
for i in range(N - 2, 0, -1):
	inv[i] = inv[i + 1] * (i + 1) % MOD

def solve(n, s):
	i = 1
	pairs = 0
	zeros = int(s[0] == '0')
	while i < n:
		if s[i] == '1':
			if s[i - 1] == '1':
				pairs += 1
				if i + 1 < n and s[i + 1] == '0':
					zeros += 1
				i += 2
			else:
				i += 1
		else:
			zeros += 1
			i += 1
	ans = fac[zeros + pairs] * inv[zeros] * inv[pairs] % MOD
	print(ans)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	solve(n, s)


def ncr(m, r, p):
	num = den = 1
	for i in range(r):
		num = num * (m - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
for _ in range(int(input())):
	n = int(input())
	strin = str(input())
	arr = []
	for i in strin:
		arr.append(int(i))
	m = 0
	x = 0
	r = 0
	while x < n:
		if arr[x] == 0:
			x += 1
			m += 1
		elif x < n - 1 and arr[x] == arr[x + 1] == 1:
			m += 1
			x += 2
			r += 1
		else:
			x += 1
	print(ncr(m, r, 998244353))


import sys
from sys import stdin

def modfac(n, MOD):
	f = 1
	factorials = [1]
	for m in range(1, n + 1):
		f *= m
		f %= MOD
		factorials.append(f)
	inv = pow(f, MOD - 2, MOD)
	invs = [1] * (n + 1)
	invs[n] = inv
	for m in range(n, 1, -1):
		inv *= m
		inv %= MOD
		invs[m - 1] = inv
	return (factorials, invs)

def modnCr(n, r):
	return fac[n] * inv[n - r] * inv[r] % mod
mod = 998244353
(fac, inv) = modfac(200000, mod)
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	n = int(stdin.readline())
	s = list(stdin.readline()[:-1])
	c = 0
	zlis = [-1]
	for i in range(n):
		if s[i] == '0':
			zlis.append(i)
	zlis.append(n)
	for i in range(len(zlis) - 1):
		c += (zlis[i + 1] - zlis[i] - 1) // 2
	ANS.append(modnCr(c + len(zlis) - 2, c) % mod)
print('\n'.join(map(str, ANS)))


num_inp = lambda : int(input())
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()
MOD = 998244353
f = [1, 1]

def factorial(x):
	l = len(f)
	while l <= x:
		f.append(f[l - 1] * l % MOD)
		l += 1
	return f[x]
T = int(input())
k = [1]
for i in range(T):
	n = int(input())
	arr = input()
	h = dict()
	p = [0]
	r = 0
	s = 0
	r = arr.count('11')
	s = arr.count('0')
	k = [1]
	(pf, zf) = (factorial(r), factorial(s))
	print(factorial(r + s) * pow(pf, -1, MOD) % MOD * pow(zf, -1, MOD) % MOD)


import itertools, math
mod = 998244353

def chess(l):
	grouped = [len(list(v)) // 2 for (i, v) in itertools.groupby(l) if i == '1']
	x = l.count('0')
	y = sum(grouped)
	return math.comb(x + y, y) % mod
ans = []
t = int(input())
for i in range(t):
	n = int(input())
	l = list(input())
	ans.append(chess(l))
for i in ans:
	print(i)


import sys
input = sys.stdin.buffer.readline
mod = 998244353

def cmb(n, r):
	if r < 0 or r > n:
		return 0
	return g1[n] * g2[r] * g2[n - r] % mod
N = 300000
g1 = [1] * (N + 3)
for i in range(2, N + 3):
	g1[i] = g1[i - 1] * i % mod
g2 = [0] * len(g1)
g2[-1] = pow(g1[-1], mod - 2, mod)
for i in range(N + 1, -1, -1):
	g2[i] = g2[i + 1] * (i + 1) % mod
inv = [0] * (N + 3)
for i in range(1, N + 3):
	inv[i] = g2[i] * g1[i - 1] % mod
for t in range(int(input())):
	N = int(input())
	A = list(input())[:N]
	for i in range(N):
		A[i] -= 48
	X = [0]
	for i in range(N):
		if A[i]:
			if X[-1] == 2:
				X.append(0)
			X[-1] += 1
		else:
			if X[-1] != 0:
				X.append(0)
			X.append(0)
	if max(X) <= 1:
		print(1)
		continue
	if A[-1] ^ 1:
		del X[-1]
	V = X.count(2)
	W = X.count(0)
	print(cmb(W + V, V))


M = 998244353
for _ in range(int(input())):
	n = int(input())
	s = input()
	i = 0
	(a, b) = (0, 0)
	while i < n:
		l = 1
		while i + 1 < n and s[i + 1] == s[i]:
			i += 1
			l += 1
		if s[i] == '1':
			a += l // 2
		else:
			b += l
		i += 1
	p = 1
	for i in range(a + 1, a + b + 1):
		p = p * i % M
	for i in range(1, b + 1):
		p = p * pow(i, -1, M) % M
	print(p)


from math import factorial
from sys import *
mod = 998244353

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline()
	x = s.count('0')
	r = 0
	i = 1
	while i < n:
		if s[i] == s[i - 1] and s[i] == '1':
			r += 1
			i += 2
		else:
			i += 1
	stdout.write(str(ncr(x + r, r, mod)) + '\n')


import sys
input = lambda : sys.stdin.readline().strip()
mod = 998244353
mx = 100005
fac = [1] * mx
for i in range(2, mx):
	fac[i] = fac[i - 1] * i % mod
ifac = [1] * mx
ifac[mx - 1] = pow(fac[mx - 1], mod - 2, mod)
for i in range(mx - 2, 1, -1):
	ifac[i] = (i + 1) * ifac[i + 1] % mod

def solve():
	n = int(input())
	s = input()
	(z, o) = (0, 0)
	i = 0
	while i < n:
		if s[i] == '0':
			z += 1
		elif i + 1 < n and s[i + 1] == '1':
			i += 1
			o += 1
		i += 1
	return fac[z + o] * ifac[z] % mod * ifac[o] % mod
for _ in range(int(input())):
	print(solve())


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	cnt = []
	while n % 2 == 0:
		cnt.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt.append(i)
			n = n / i
	if n > 2:
		cnt.append(int(n))
	return cnt

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s
for xyz in range(0, int(input())):
	mod = 998244353
	n = int(input())
	s = input()
	zc = s.count('0')
	i = 0
	pc = 0
	while i < n - 1:
		if s[i] == s[i + 1] == '1':
			i += 1
			pc += 1
		i += 1
	print(ncr(zc + pc, pc, mod))