CF2129D Permutation Blackhole

Description

For a permutation $ p_1, p_2, \ldots, p_n $ of length $ n $ , the corresponding coloring sequence $ s $ can be obtained by the following coloring process: - Initially, there are $ n $ white cells indexed from $ 1 $ to $ n $ from left to right. At second $ 0 $ , the score of each cell is $ 0 $ . - At second $ i $ ( $ 1 \le i \le n $ ), - If $ i > 1 $ , find the nearest black cell to the cell $ p_i $ , and increase the score of that cell by $ 1 $ . In case there are multiple nearest black cells, choose the cell with the lowest index. Cell $ y $ is called the nearest black cell to cell $ x $ only if cell $ y $ is black and there is no black cell $ z $ satisfying $ |x-z|

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^3 $ ). The description of the test cases follows. For each test case, the first line contains an integer $ n $ ( $ 2 \leq n \leq 100 $ ). The second line contains $ n $ integers $ s_1, s_2, \ldots, s_n $ ( $ -1 \leq s_i \leq n-1 $ ). Here, $ s_i=-1 $ means $ s_i $ has not been determined. And $ s_i \neq -1 $ means $ s_i $ has already been fixed. It is guaranteed that the sum of $ n^2 $ over all test cases does not exceed $ 10^4 $ .

Output Format

For each test case, output the total of different permutations $ p_1, p_2, \ldots, p_n $ that can produce the coloring sequence, modulo $ 998\,244\,353 $ .

Explanation/Hint

In the first test case, $ p=[3,1,2] $ and $ p=[3,2,1] $ can produce the coloring sequence $ s=[-1,-1,1] $ . For $ p=[3,1,2] $ , the coloring process is shown as the following picture. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/022aefcacbea3595de9f889d1bca0dbf59cc5e17.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/279519edbbfd510cf0e6f20008881b2f63e471e6.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/1dae7117c3f13b48c2b0670fa79993b6b0f449ad.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/2e8dd4d05fcc92cd2a3497a42a1cbf9762f76b30.png) The grid at seconds $ 0 $ , $ 1 $ , $ 2 $ , and $ 3 $ respectively when $ p=[3,1,2] $ .For $ p=[3,2,1] $ , the coloring process is shown as the following picture. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/022aefcacbea3595de9f889d1bca0dbf59cc5e17.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/279519edbbfd510cf0e6f20008881b2f63e471e6.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/b1e2364c16ab285fa9c973c2bdd89c28ec014aef.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2129D/3d85d5610273aa8da29be8394d77bb2e1dfc3d34.png) The grid at seconds $ 0 $ , $ 1 $ , $ 2 $ , and $ 3 $ respectively when $ p=[3,2,1] $ .