Problem Statement
You are given a binary tree with $N$ vertices. The vertices are numbered $1$ to $N$, with vertex $1$ being the root. The $i$-th edge $(1\leq i \leq N-1)$ connects vertex $i+1$ and vertex $P_i\ (\leq i)$ bidirectionally.
There are one basket and $M$ balls on this tree. The balls are numbered $1$ to $M$, and each ball $j$ has a designated start vertex $S_j$ and goal vertex $T_j$. Initially, the basket is empty and placed at vertex $1$, and the balls are placed at their respective start vertices.
You can perform the following operation any number of times in any order.
- Let
$v$be the current vertex where the basket is placed. Do one of the following: - Choose one edge connected to vertex
$v$, and move the basket along that edge to the adjacent vertex. The balls inside the basket move together with it.- Choose a ball with the start vertex
$v$that is still placed at$v$, and put it into the basket. This operation can only be performed if the basket contains fewer than$K$balls (that is, the basket cannot contain$K+1$or more balls). - Choose a ball with the goal vertex
$v$from the basket and take it out, placing it at vertex$v$.
- Choose a ball with the start vertex
A sequence of operations is called a good operation sequence if and only if the basket is eventually empty and placed at vertex $1$, and the balls are eventually placed at their respective goal vertices.
Since it is tiring to move the basket many times, the basket's movement path should traverse each edge exactly twice before returning to vertex $1$. Find the number, modulo $998244353$, of those paths such that a good operation sequence exists following that path.
Constraints
$2\leq N \leq 10^4$$1\leq M \leq 2\times 10^5$$1\leq K \leq 10^3$$1\leq P_i \leq i$- For every
$v\ (1\leq v \leq N)$, there are at most two$i$'s such that$P_i=v$. $1\leq S_j, T_j \leq N$$S_j \neq T_j$- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M K
P_1 P_2 \dots P_{N-1}
S_1 T_1
S_2 T_2
\vdots
S_M T_M
Output
Print the number, modulo $998244353$, of paths traversing every edge exactly twice before returning to vertex $1$ such that a good operation sequence exists following that path.
样例
5 2 1
1 1 3 3
2 4
5 3
1
5 2 2
1 1 3 3
2 4
5 3
2
15 4 2
1 2 1 4 2 3 4 7 3 7 5 9 11 8
14 12
5 4
13 15
5 12
8
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。