| Good Bye 2025 |
|---|
| Finished |
Define the unique ornamental coloring of a rooted tree$$$^{\text{∗}}$$$ as the following vertex coloring:
On his quest to conquer a forest of Christmas trees, Yuuki encountered an ornamentally colored tree $$$T$$$ with $$$n$$$ vertices labeled from $$$1$$$ to $$$n$$$, rooted at vertex $$$1$$$.
Yuuki considers the tree conquered if and only if at least one of the following conditions holds:
To conquer the tree, Yuuki can apply the following operation on $$$T$$$ an arbitrary number of times (possibly zero):
A possible application of the operation in the first test case. The resulting tree is conquered since all white vertices lie on the path between vertices $$$1$$$ and $$$3$$$. Compute the number of distinct$$$^{\text{‡}}$$$ conquered trees that Yuuki can construct by applying the above operation an arbitrary number of times on $$$T$$$. Since the answer may be large, output it modulo $$$998\,244\,353$$$.
Note that Yuuki cannot stop midway through an operation (in particular, he must recolor the tree before checking if it is conquered). Additionally, Yuuki is allowed to apply the operation even if the tree is already conquered.
$$$^{\text{∗}}$$$A tree is a connected graph without cycles.
$$$^{\text{†}}$$$A subtree of vertex $$$v$$$ is the subgraph of $$$v$$$, all its descendants, and all the edges between them.
$$$^{\text{‡}}$$$Two trees are considered distinct if and only if there exists a pair of vertices such that there is an edge between them in one of the trees, and not in the other.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in $$$T$$$.
Then $$$n-1$$$ lines follow, the $$$i$$$-th line containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1\le u_i \lt v_i\le n$$$) — the two vertices that the $$$i$$$-th edge connects.
It is guaranteed that the given edges form a tree.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output a single integer — the number of distinct conquered trees that can be constructed from $$$T$$$, modulo $$$998\,244\,353$$$.
541 21 33 451 21 31 41 551 22 31 44 561 22 32 42 65 6112 106 81 63 75 115 85 94 76 72 6
411682048
In the first test case, below are the four conquered trees that can be constructed and a sequence of operations that constructs each one.
| Illustration | |
| ![]() |
| ![]() |
| ![]() |
| ![]() |
In the second test case, Yuuki cannot apply the operation on $$$T$$$ since there are no white vertices. Additionally, $$$T$$$ is already conquered since there are no white vertices. Thus, the answer is $$$1$$$.
| Name |
|---|


