#agc058f. [agc058_f]Authentic Tree DP
[agc058_f]Authentic Tree DP
Problem Statement
For an undirected tree , let us define a rational number as follows.
- Let be the number of vertices in .
- If : Let .
- If :
- For an edge in , we denote by and the two trees that result from deleting from (in arbitrary order).
- Let $f(t)=(\\sum_{e \\in t} f(t_x(e)) \\times f(t_y(e)))/n$.
You are given a tree with vertices numbered to . The -th edge connects Vertex and Vertex .
Find the value .
What is a rational number ?
Under the Constraints of this problem, when the sought rational number is represented as , it can be proved that . Therefore, there is a unique integer such that $R \\times Q \\equiv P \\pmod{998244353}, 0 \\leq R < 998244353$. Find this .
Constraints
- The given graph is a tree.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2
1 2
Sample Output 1
499122177
We have .
Sample Input 2
3
1 2
2 3
Sample Output 2
332748118
We have .
Sample Input 3
4
1 2
2 3
3 4
Sample Output 3
103983787
Sample Input 4
10
4 5
1 9
6 1
8 4
5 9
4 7
3 10
5 2
4 3
Sample Output 4
462781191