| SDU Open 2023 |
|---|
| Finished |
It is very easy to get lost in dense jungles, and sometimes the only way to find a way out is to wander. Fortunately, very experienced travelers have visited our jungle and have laid out paths.
There are only $$$n$$$ trees and $$$n-1$$$ paths, each of which connects two trees. Additionally, it is known that between any two trees there is exactly one route along the paths, without passing through the same path twice.
Over the past few days, $$$q$$$ people have independently found themselves in the jungle without a map or other means of navigation. You know from the rescuers' records that the $$$i$$$-th person started his journey at tree $$$s_i$$$ and wandered until he reached tree $$$t_i$$$ for the first time, where he found a note from the rescuers with a way out of the jungle.
Each of these people wandered completely randomly, looking at all possible paths he could take at each step, and choosing any of them with equal probability, reaching the other end of the path and repeating this process. The probability of moving from tree $$$u$$$ to the tree connected by a path $$$v$$$ was $$$\frac{1}{c_u}$$$, where $$$c_u$$$ is the total number of paths at tree $$$u$$$. Each of them never gave up and never stayed at the same tree, constantly walking along the paths and looking for a way out.
However, the records did not indicate how long each of these lost people wandered. To estimate this number, you need to find the expected number of steps required for each person to reach tree $$$t_i$$$ from tree $$$s_i$$$.
The first line contains two integers $$$n$$$ and $$$q$$$ ($$$2 \leq n, q \leq 2 \cdot 10^5$$$) — the number of trees in the jungle and the number of lost people.
The next $$$n-1$$$ lines contain descriptions of the paths. Each line contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq n$$$), meaning that trees $$$u$$$ and $$$v$$$ are connected by a path.
The next $$$q$$$ lines contain two integers $$$s_i$$$ and $$$t_i$$$ ($$$1 \leq s_i, t_i \leq n$$$, $$$s_i \neq t_i$$$) — the initial and final tree for each lost person.
Output $$$q$$$ lines, each containing one integer — the expected number of steps modulo $$$998\,244\,353$$$ required for each person to reach tree $$$t_i$$$ from tree $$$s_i$$$.
Formally, let $$$M=998\,244\,353$$$. It can be shown that the answer can be represented as an irreducible fraction $$$\frac{p}{q}$$$, where $$$p$$$ and $$$q$$$ are integers. Output one integer, equal to $$$(p \cdot q^{-1}) \bmod M$$$.
3 3 1 2 1 3 2 3 1 2 2 1
4 3 1
| Name |
|---|


