There is a weighted tree with n vertices and n−1 edges. each edge has a value. Let f(v,u) be the number of values that appear exactly once on the edges of a simple path between vertices v and u.
Now you randomly choose k vertices, which is x1,x2,…,xk. For all k=1,2,…,n, calculate the expectation of ek=∑i=1k∑j=i+1kf(xi,xj) modulo 998244353998244353
This problem contains multiple test cases.The first line of input contains a single integer t(1≤t≤2⋅10^5)---the number of test cases.The desc
In a test, the first line contains a single integer n (2≤n≤2⋅10^5) --- the number of island
Each of the next n−1 lines contains three integers v,u and x (1≤v,u,x≤n) --- This means that this egde connects u and v, and the value of this edge is x.
It's guarantee the sum of n over all test cases doesn't exceed 10^6.
2
2
1 2 1
3
1 2 1
1 3 2
1
332748115