#ZH202503. Love Wins All

Love Wins All

Description

It's a loving community!

There are nn residents in the community, and each resident i(1in)i (1 \leq i \leq n) in the community has a unique resident ai(1in)a_i (1 \leq i \leq n) in the community whom he/she loves so much. Each two residents love different residents. A resident can love himself / herself. It is guaranteed that nn is even.

One day, a bad thing happens: They need to choose 22 residents to be forbidden to get married forever.

And to prevent such a thing from happening in the future, the rest n2n−2 residents decide to get married as n21\frac{n}{2}−1 couples, each couple consisting of 22 persons (of course). It makes no sense that a couple consists of resident xx and resident yy while neither xx loves yy nor yy loves xx, so such a thing never happens.

So, as the planner, you need to figure out how you can arrange this. You want to know the number of different marriage plans. Two marriage plans are considered different if at least one of the following conditions is satisfied:

  • In one plan, a person ii is married, and in the other, he/she is not.
  • In one plan, a person ii is married to jj, and in the other, he/she is not married to jj.

As the number of plans can be quite enormous, output it modulo 998244353998244353.

Input

Each test contains multiple test cases. The first line contains the number of test cases T(1T104)T (1 \leq T \leq 10^4).

Each test case consists of two lines.

The first line contains 11 integer n(4n5×105)n (4 \leq n \leq 5 \times 10^5), the number of residents in the community. It's guaranteed that nn is even.

The second line contains nn integers a1,a2,,an(1ain)a_1,a_2,\dots,a_n (1 \leq a_i \leq n), where aia_i​ represents the one that the resident ii loves. It is guaranteed that if ij(1i,jn)i \neq j (1 \leq i,j \leq n), aiaja_i \neq a_j.

It is guaranteed that n\sum n over all test cases in one test will not exceed 5×1055 \times 10^5.

Output

For each test case, output 11 integer: the number of different marriage plans modulo 998244353998244353.

Example

2
4
1 3 4 2
6
3 4 5 6 2 1
3
9