#431. Bookshop

Bookshop

Description

DreamGrid will go to the bookshop tomorrow. There are nn books in the bookshop in total, labeled by 1,2,,n1,2,\dots,n, connected by n1n-1 bidirectional roads like a tree. Because DreamGrid is very rich, he will buy the books according to the strategy below: Select two books xx and yy. Walk from xx to yy along the shortest path on the tree, and check each book one by one, including the xx-th book and the yy-th book. For each book being checked now, if DreamGrid has enough money (not less than the book price), he'll buy the book and his money will be reduced by the price of the book. In case that his money is less than the price of the book being checked now, he will skip that book. BaoBao is curious about how rich DreamGrid is. You will be given qq queries, in each query you will be given three integers xix_i, yiy_i and ziz_i. Assume DreamGrid will bring ziz_i dollars before buying books, and will walk from xix_i to yiy_i, you are asked to tell BaoBao the amount of money DreamGrid will have after he checking all the visited books.

Format

Input

The first line contains a single integer TT (1T5001 \leq T \leq 500), the number of test cases. For each test case:

The first line of the input contains two integers nn and qq (1n,q1000001 \leq n,q \leq 100\,000), denoting the number of books in the bookshop and the number of queries.

The second line contains nn integers p1,p2,,pnp_1,p_2,\dots,p_n (1pi1091\leq p_i\leq 10^9), denoting the price of each book.

Each of the next n1n-1 lines contains two integers uiu_i and viv_i (1ui,vin1 \leq u_i, v_i \leq n, uiviu_i \neq v_i), denoting a bidirectional road between uiu_i and viv_i. It is guaranteed that the roads form a tree.

In the next qq lines, the ii-th line contains three integers xix_i, yiy_i and ziz_i (1xi,yin1\leq x_i,y_i\leq n, 1zi1091\leq z_i\leq 10^9), describing the ii-th query.

It is guaranteed that the sum of all nn is at most 800000800\,000, and the sum of all qq is at most 800000800\,000.

Output

For each query, print a single line containing an integer, denoting the amount of money DreamGrid will have after he checking all the visited books.

Samples

1
5 5
5 2 7 4 6
1 2
1 3
2 4
2 5
4 5 10
5 4 10
4 5 12
5 3 12
3 5 11
4
2
0
4
2