You are given a rooted tree$$$^{\text{∗}}$$$ with $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The root is the vertex $$$1$$$.
A permutation$$$^{\text{†}}$$$ $$$p_1,p_2,\dots,p_n$$$ is good if and only if, for each $$$1 \le i \le n$$$, at least one of the following conditions is true:
Count the number of good permutations of length $$$n$$$, modulo $$$998\,244\,353$$$.
$$$^{\text{∗}}$$$A tree is a connected graph without cycles. A rooted tree is a tree where one vertex is special and called the root.
$$$^{\text{†}}$$$A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array), and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).
$$$^{\text{‡}}$$$An ancestor of vertex $$$v$$$ is any vertex on the simple path from $$$v$$$ to the root, including the root, but not including $$$v$$$. The root has no ancestors.
$$$^{\text{§}}$$$A descendant of vertex $$$v$$$ is any vertex $$$u$$$ for which $$$v$$$ is an ancestor. No vertex is its own descendant.
The first line contains $$$t$$$ ($$$1 \le t \le 2\,500$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 5\,000$$$) — the number of vertices.
The second line contains $$$n - 1$$$ integers $$$a_2, a_3, \ldots, a_n$$$ ($$$1 \le a_i \le i-1$$$) — $$$a_i$$$ represents the parent of the vertex $$$i$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5\,000$$$.
For each test case, output one number — the number of good permutations modulo $$$998\,244\,353$$$.
5336713
3 6 20 75 237554682
In the first test case, the good permutations are $$$[1,2,3]$$$,$$$[2,1,3]$$$, and $$$[3,2,1]$$$.
In the second test case, all $$$3!=6$$$ permutations are good.