

MapTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 691 Accepted Submission(s): 234 Problem Description There are N pieces of fragments, and we¡¯re going to select some of them to form a map. Some fragments can be selected into the map directly (named 1level fragments), while each of the rest follows exactly one fragment as its prior fragment. If B follows A and A is an ilevel fragment, then B is defined as an (i + 1)  level fragment, and B can be selected only if A has been selected before. Besides, a fragment is followed by at most one other fragment. Each fragment is assigned with a reliability. The reliability of the whole map is sum up by two parts: 1.The sum of reliabilities of all selected fragments; 2.If there are x_{i} ilevel fragments in total and we select y_{i}(y_{i} > 1) fragments among them to form the map, the reliability would increase by ,where S_{i} denotes the sum of reliabilities of selected fragments in level i. Please figure out the expectation of reliability of the map under the condition that all valid selections are equiprobable. At least one fragment should be selected. Input There are several test cases. The number of test cases T (T<=10) occurs in the first line of input. For each test case: The first line consists of two integers N, M (1<=N<=10000,0<=M<N), indicating the number of fragments and relationships respectively. The second line contains N integers, which describes the reliability of each fragment. The given reliability ranges from 1 to 100, inclusive. Each of the following M lines contains two integers A and B, which denotes B follows A(0<=A,B<=N1). You may assume that the number of 1level fragments are no more than 10, and levels will not exceed 1000. No fragment will follow itself directly or indirectly. Output For each test case, output the expectation with 3 decimal places. Sample Input
Sample Output
Hint In the first sample, there¡¯re three ways of selections: {0,1}, {0},{1},which respectively generates 6, 1 and 2 of reliability. Hence, the expectation is 3. Author BUPT Source  
