{"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\"\u003eAcesrc is a famous tourist at Nanjing University second to none. During this summer holiday, he, along with Zhang and Liu, is going to travel to Hong Kong. There are $n$ spots in Hong Kong, and $n - 1$ bidirectional sightseeing bus routes connecting these spots. They decide to visit some spots by bus.\u003cbr\u003e\u003cbr\u003eHowever, Zhang and Liu have different preferences for these spots. They respectively set a satisfactory value for each spot. If they visit the $i$th spot, Zhang will obtain satisfactory value $a_i$, and Liu will obtain $b_i$. Starting with Zhang, they alternately decide the next spot to visit for the sake of fairness. There must be a bus route between the current spot and the next spot to visit. Moreover, they would never like to visit a spot twice. If anyone can\u0027t find such a next spot to visit, they have no choice but to end this travel.\u003cbr\u003e\u003cbr\u003eZhang and Liu are both super smart competitive programmers. Either want to maximize the difference between his total satisfactory value and the other\u0027s. Now Acesrc wonders, if they both choose optimally, what is the difference between total satisfactory values of Zhang and Liu?\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input consists of a single integer $T$ $(1 \\leq T \\leq 30)$, denoting the number of test cases.\u003cbr\u003e\u003cbr\u003eFor each test case, the first line contains a single integer $n$ $(1 \\leq n \\leq 10^5)$, denoting the number of spots. Each of the next two lines contains $n$ integers, $a_1, a_2, \\cdots, a_n$ and $b_1, b_2, \\cdots, b_n$ $(0 \\leq a_i, b_i \\leq 10^9)$, denoting the \u003cbr\u003esatisfactory value of Zhang and Liu for every spot, respectively. Each of the last $n - 1$ lines contains two integers $x, y$ $(1 \\leq x, y \\leq n, x \\neq y)$, denoting a bus route between the $x$th spot and the $y$th spot. It is reachable from any spot to any other spot through these bus routes.\u003cbr\u003e\u003cbr\u003eIt is guaranteed that the sum of $n$ does not exceed $5.01 \\times 10^5$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a single integer in one line, the difference of total satisfactory values if they both choose optimally."}},{"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\r\n1 1 1\r\n0 2 3\r\n1 2\r\n1 3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}