#P9893. Average
Average
Average
Problem Description
You are given a tree with nodes. Every node has its value . The value of a on the tree is equal to $$\frac{\sum_{w \in path(u,v)} a_w}{len(u,v)}$$ where is the shortest path from to , means the number of nodes in . You have to answer questions like what is the maximum possible value of a path with length greater than or equal to . Unfortunately, the value of nodes will increase. So you need to answer the question after each change.
Input
Each test contains multiple test cases. The first line contains an integer , indicating the number of test cases. The description of test cases follows. The first line contains two integers , . The second line contains integers . The following lines contains integers and , indicating an edge between vertices and . It is guaranteed that the given edges form a tree. The next line contains a integer . The following lines contains integers , indicating that the value of node will increase . It is guaranteed that the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
Output
Output the answer , indicating the value is and . If no such path, output "".
Sample Input
2
6 2
6 16 6 15 5 4
1 2
2 3
2 4
2 5
4 6
2
1 4
3 5
14 1
12 19 9 17 9 10 11 18 9 19 10 14 18 8
1 2
2 3
1 4
1 5
4 6
2 7
7 8
8 9
6 10
6 11
1 12
11 13
3 14
5
10 3
2 8
7 9
5 6
2 1000000000
Sample Output
31/2
31/2
22/1
27/1
27/1
27/1
1000000027/1
Source
2023“钉耙编程”中国大学生算法设计超级联赛(9)