Now, suppose you are the military minister of Country A, and you should decide which roads to close in advance to maximize the total importance level of all components.
The first line contains an integer, indicating the number of test cases.
For each test case, the first line contains two integers, indicating the number of cities and roads in Country A.
The second line contains
integers
, indicating the importance level of each city.
Each of the nextlines contains two integers
, indicating that there is a road between City
and City
![]()
.
It is guaranteed that.
Due to the huge input, it is highly recommended to use faster I/O.
For each test case, print an integer in one line, indicating the maximal sum of the importance level of each component.