This is the easy version of the problem. The only difference between the two versions is the constraint on $$$k$$$. You can make hacks only if all versions of the problem are solved.
In this statement, all strings are $$$0$$$-indexed.
For two strings $$$a$$$, $$$b$$$ of the same length $$$p$$$, we define the following definitions:
You are given two binary strings $$$s$$$ and $$$t$$$ of length $$$2^{k+1}$$$ each. Both strings may contain missing characters (denoted by the character '?'). Your task is to count the number of ways to replace the missing characters in both strings with the characters '0' or '1' such that:
As the result can be very large, you should print the value modulo $$$998\,244\,353$$$.
The first line of the input contains a single integer $$$k$$$ ($$$1 \le k \le 7$$$).
The second line of the input contains string $$$s$$$ of size $$$2^{k+1}$$$, consisting of the characters '0', '1' and '?'.
The third line of the input contains string $$$t$$$ of size $$$2^{k+1}$$$, consisting of the characters '0', '1' and '?'.
It is guaranteed that both strings $$$s$$$ and $$$t$$$ contains no more than $$$2^k$$$ character '0' or '1'.
Print a single integer — the answer to the problem modulo $$$998\,244\,353$$$.
1 0011 0101
1
1 0011 0110
0
1 0??1 01??
2
2 000????? 01010101
3
2 0??????? 1???????
68
5 0101010101010101010101010101010101010101010101010101010101010101 ????????????????????????????????????????????????????????????????
935297567
In the first example, we can check that the condition $$$h(s, c) \ge 2^k$$$ for all cyclic shift $$$c$$$ of $$$t$$$ is satisfied. In particular:
In the second example, there exists a cycle shift $$$c$$$ of $$$t$$$ such that $$$h(s, c) < 2^k$$$ (in particular, $$$c = \mathtt{0011}$$$, and $$$h(s, c) = h(\mathtt{0011}, \mathtt{0011}) = 0$$$).
In the third example, there are $$$2$$$ possible ways to recover the missing characters:
In the fourth example, there are $$$3$$$ possible ways to recover the missing characters:
Name |
---|