Maze Runner

Limits 2s, 1.0 GB

Like always Alice and Bob are playing games. Alice gives Bob a tree and challenged him in the following game :

Now Alice wants to know the probability of his winning in this game. As Bob is busy thinking about why the name of this problem is “Maze Runner”, he needs your help to solve this problem.

Input

Input starts with an integer T which denotes the number of the test cases. The first line of each test case is an integer N which is the number of nodes in the tree. The next line contains N integers which are the points of each node. In the next N-1 line, there will be two integers U and V which indicate there is an undirected edge between nodes U and V.

Output

For each test case output a real number which is the probability value which is asked in the problem. You'll get accepted if the difference between your answer and the standard answer is no more than 10-6.

Sample

InputOutput
2

3
2 2 2
1 2
1 3

6
2 1 1 1 1 1
1 2
2 3
3 5
3 6
2 4
0.0000000000
0.5714285714

In graph theory, a tree is an undirected graph in which any two vertices are connected by exactly one path, or equivalently a connected acyclic undirected graph.