#P7774. Total Eclipse

Total Eclipse

Total Eclipse

Problem Description

There are nn cities and mm bidirectional roads in Byteland. These cities are labeled by 1,2,,n1,2,\dots,n, the brightness of the ii-th city is bib_i. Magician Sunset wants to play a joke on Byteland by making a total eclipse such that the brightness of every city becomes zero. Sunset can do the following operations for arbitrary number of times: · Select an integer kk (1kn1\leq k\leq n). · Select kk distinct cities c1,c2,,ckc_1,c_2,\dots,c_k (1cin1\leq c_i\leq n) such that they are connected with each other. In other words, for every pair of distinct selected cities cic_i and cjc_j (1i<jk)(1\leq i<j\leq k), if you are at city cic_i, you can reach city cjc_j without visiting cities not in {c1,c2,,ck}\{c_1,c_2,\dots,c_k\}. · For every selected city cic_i (1ik1\leq i\leq k), decrease bcib_{c_i} by 11. Note that Sunset will always choose kk with the maximum possible value. Now Sunset is wondering what is the minimum number of operations he needs to do, please write a program to help him.

Input

The first line of the input contains a single integer TT (1T101 \leq T \leq 10), the number of test cases. For each case, the first line of the input contains two integers nn and mm (1n1000001 \leq n \leq 100\,000, 1m2000001\leq m\leq 200\,000), denoting the number of cities and the number of roads. The second line of the input contains nn integers b1,b2,,bnb_1,b_2,\dots,b_n (1bi1091\leq b_i\leq 10^9), denoting the brightness of each city. Each of the following mm lines contains two integers uiu_i and viv_i (1ui,vin,uivi1\leq u_i,v_i\leq n,u_i\neq v_i), denoting an bidirectional road between the uiu_i-th city and the viv_i-th city. Note that there may be multiple roads between the same pair of cities.

Output

For each test case, output a single line containing an integer, the minimum number of operations.

Sample Input

1
3 2
3 2 3
1 2
2 3

Sample Output

4

Source

2020 Multi-University Training Contest 2