{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eThere are $n$ cities and $m$ bidirectional roads in Byteland. These cities are labeled by $1,2,\\dots,n$, the brightness of the $i$-th city is $b_i$.\u003cbr\u003e\u003cbr\u003eMagician 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:\u003cbr\u003e\u003cbr\u003e· Select an integer $k$ ($1\\leq k\\leq n$).\u003cbr\u003e\u003cbr\u003e· Select $k$ distinct cities $c_1,c_2,\\dots,c_k$ ($1\\leq c_i\\leq n$) such that they are connected with each other. In other words, for every pair of distinct selected cities $c_i$ and $c_j$ $(1\\leq i\u0026lt;j\\leq k)$, if you are at city $c_i$, you can reach city $c_j$ without visiting cities not in $\\{c_1,c_2,\\dots,c_k\\}$.\u003cbr\u003e\u003cbr\u003e· For every selected city $c_i$ ($1\\leq i\\leq k$), decrease $b_{c_i}$ by $1$.\u003cbr\u003e\u003cbr\u003eNote that Sunset will always choose $k$ 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.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains a single integer $T$ ($1 \\leq T \\leq 10$), the number of test cases.\u003cbr\u003e\u003cbr\u003eFor each case, the first line of the input contains two integers $n$ and $m$ ($1 \\leq n \\leq 100\\,000$, $1\\leq m\\leq 200\\,000$), denoting the number of cities and the number of roads.\u003cbr\u003e\u003cbr\u003eThe second line of the input contains $n$ integers $b_1,b_2,\\dots,b_n$ ($1\\leq b_i\\leq 10^9$), denoting the brightness of each city.\u003cbr\u003e\u003cbr\u003eEach of the following $m$ lines contains two integers $u_i$ and $v_i$ ($1\\leq u_i,v_i\\leq n,u_i\\neq v_i$), denoting an bidirectional road between the $u_i$-th city and the $v_i$-th city. Note that there may be multiple roads between the same pair of cities."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a single line containing an integer, the minimum number of operations."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n3 2\r\n3 2 3\r\n1 2\r\n2 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}