| RCPCamp 2023 Day 1 |
|---|
| Закончено |
G dreamt about an unusual permutation $$$p_1, p_2, \ldots, p_n$$$.
A permutation is considered unusual if, for each element $$$p_i$$$, exactly one of the following conditions is true:
For example, $$$[1]$$$, $$$[2,1,3,4]$$$ and $$$[1,2,3,4,5]$$$ are unusual, while $$$[3,1,2]$$$ and $$$[3,2,5,4,1]$$$ are not.
Unfortunately, after waking up, G remembers only some of the elements from $$$p$$$. As such, he now wonders how many unusual permutations containing the remaining numbers exist.
Since the answer can be very large, G only wants to know its remainder modulo $$$10^9+7$$$.
Each test contains multiple test cases. The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 2\cdot 10^4$$$) — the number of testcases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in the permutation.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0 \le a_i \le n$$$). If $$$a_i=0$$$, then G forgot the value of $$$p_i$$$. Otherwise, G knows that $$$p_i$$$ must be equal to $$$a_i$$$. It is guaranteed that there are no two indices $$$1 \le i \lt j \le n$$$ for which $$$0 \neq a_i=a_j$$$.
It is guaranteed that the sum of $$$n$$$ across all testcases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output a single integer, denoting the number of unusual permutations containing the remaining numbers. Since the answer can be very large, print its remainder modulo $$$10^9+7$$$.
442 0 0 433 1 250 0 0 4 010
2 0 4 1
The bolded numbers denote the elements that G remembered:
| Название |
|---|


