Jiulian is a girl who loves creating problems.
After this year's World Final, Jiulian became particularly fond of computational geometry, so she decided to include a computational geometry problem in the NOI contest as well: this is a problem where only the title is related to computational geometry.
First, Jiulian provides a rooted tree $T$ with $n (n \ge 2)$ nodes, where the root is node 1. A leaf node is defined as any node other than the root with a degree of exactly 1. The figure below shows an example of a tree $T$, where the set of leaf nodes is $\{3, 4, 5\}$.
Next, using this tree, Jiulian constructs a sequence $A$: Perform a depth-first traversal of the tree starting from the root, visiting children in increasing order of their indices to obtain a DFS order of the tree $T$. Then, following the order of appearance in the DFS sequence, Jiulian arranges all leaf nodes in a row to obtain a sequence $A$.
Furthermore, using sequence $A$, Jiulian defines the distance $d(u, v)$ between two leaf nodes $u$ and $v$: assuming $u$ is the $i$-th element in $A$ and $v$ is the $j$-th element in $A$, then $d(u, v) = \min(|i - j|, |A| - |i - j|)$. Here, $|A|$ is the length of the sequence, i.e., the number of leaves in $T$, and $i, j$ refer to the positions of appearance, counting from 1.
In the example above, the sequence $A$ is $[4, 5, 3]$, where $d(3, 5) = d(3, 4) = d(4, 5) = 1$, and the positions of $3, 4, 5$ are $3, 1, 2$ respectively.
Finally, Jiulian provides a parameter $K$. Using this rooted tree $T$ and sequence $A$, we can construct an undirected graph $G$ with $n$ nodes, containing no multiple edges and no self-loops: an edge exists between two distinct nodes $u$ and $v$ if and only if they satisfy at least one of the following conditions: There exists an edge connecting $u$ and $v$ in tree $T$. In tree $T$, both $u$ and $v$ are leaf nodes and $d(u, v) \le K$.
When $K = 1$ or $2$, the graph $G$ obtained from the example above is shown in the figure below:
Now, Jiulian wants you to calculate the number of distinct Hamiltonian cycles in $G$. The answer may be very large, so please output the result modulo 998244353.
Below are some supplementary definitions: A Hamiltonian cycle $H$ of an undirected graph $G$ with no multiple edges and no self-loops is a subset of edges in $G$ such that every node has exactly two distinct incident edges in $H$, and any two nodes can reach each other directly or indirectly through edges in $H$. Two Hamiltonian cycles $H_1, H_2$ of an undirected graph $G$ with no multiple edges and no self-loops are different if and only if there exists an edge $e$ such that $e$ is in $H_1$ but not in $H_2$.
Input
The first line contains two integers $n, K$, representing the number of nodes in tree $T$ and the parameter $K$ chosen by Jiulian. The second line contains $n - 1$ integers $f_i (1 \le f_i \le i)$, where $f_i$ indicates that there is an edge $(f_i, i + 1)$ in tree $T$.
Output
Output a single integer representing the number of Hamiltonian cycles modulo 998244353.
Examples
Input 1
5 1 1 1 2 2
Output 1
2
Note
This example is identical to the one in the problem description. The two Hamiltonian cycles pass through the nodes in the order $(1, 2, 4, 5, 3)$ and $(1, 2, 5, 4, 3)$.
Subtasks
The data scale and properties for each test case are as follows:
| ID | $n$ | $K$ | Special Property | ID | $n$ | $K$ | Special Property |
|---|---|---|---|---|---|---|---|
| 1 | $\le 5$ | 11 | |||||
| 2 | $\le 10$ | $\le 3$ | None | 12 | $\le 2$ | A | |
| 3 | $\le 15$ | 13 | |||||
| 4 | $\le 20$ | 14 | |||||
| 5 | 15 | $\le 1000$ | None | ||||
| 6 | A | 16 | |||||
| 7 | $\le 1000$ | $= 1$ | 17 | $\le 3$ | A | ||
| 8 | 18 | ||||||
| 9 | None | 19 | None | ||||
| 10 | 20 |
Property A guarantees that all nodes in the tree have at most two children. For all data, it is guaranteed that $1 \le f_i \le i$ and $2 \le n \le 1000$.