#P7043. 「MCOI-03」村国

「MCOI-03」村国

Background

What did this player dream?\texttt{What did this player dream?}

What did he dream of?

$\texttt{This player dreamed of sunlight and trees.Of fire and water.}$

He dreamed of sunlight and trees. He dreamed of fire and water.

$\texttt{It dreamed it created. And it dreamed it destroyed. It dreamed it hunted,}$ and was hunted. It dreamed of shelter.\texttt{and was hunted. It dreamed of shelter.}

He dreamed of what he created, and he also dreamed of what he destroyed. It dreamed that it was hunting, and also being hunted. He dreamed of a warm shelter.

$\texttt{Hah, the original interface. A million years old, and it still works.But}$ $\texttt{ what true structure did this player create, in the reality behind the screen?}$

Ah, the original interface. After a million years, it still works. But in the reality behind the screen, what real world did he actually create?

Problem Description

Country C has NN villages and N1N-1 roads. All roads can be traveled in both directions. It is guaranteed that Little S can reach any other village from any village. The NN villages are numbered from 11 to NN.

At the beginning, Little S's favorability toward village ii is AiA_i. Little S has a MM-day vacation, and he will travel in Country C for a total of MM days. Each day, he will choose to go to the village with the highest current favorability. If there are multiple villages with the same favorability, he will choose the one with the smallest index. Suppose that on this day he goes to village XX. Then after this day ends, the favorability of all villages directly adjacent to village XX will increase by 11. That is, the favorability of villages that can be reached from XX by traveling along exactly one road will increase by 11. Since Little S has already stayed in village XX for one day, after this day ends, the favorability of village XX itself will not increase.

Now Little S wants to know which village has the highest favorability after MM days of traveling.

If there are multiple villages with the highest favorability, output the smallest index.

Input Format

This problem contains multiple testcases in a single test point.
The first line contains a positive integer TT, representing the number of testcases.
For each testcase:
The first line contains two positive integers N,MN, M, representing the number of villages and the number of travel days.
The next line contains NN integers. The ii-th integer represents the favorability AiA_i of village ii.
The next N1N-1 lines each contain two integers x,yx, y, indicating that there is a bidirectional road between village xx and village yy.

Output Format

Output one integer, representing the index of the village with the highest favorability after MM days. If there are multiple villages with the highest favorability, output the smallest index.

2
2 3
2 6
1 2
3 5
2 6 4
1 3
2 3
2
3

Hint

Sample Explanation

For the first testcase, Little S traveled in village 22 for 33 days. At the end, the favorability of villages 11 and 22 are 55 and 66, respectively. Therefore the answer is 22.

For the second testcase, at the end, the favorability of the three villages are 3,7,83, 7, 8, so the answer is 33.

Constraints

For 100%100\% of the testdata, 1N2×1061 \le N \le 2\times10^6, 1M10181 \le M \le 10^{18}, 1Ai23111 \le A_i \le 2^{31}-1, 1T101 \le T \le 10.

Test Point ID AiA_i \le N\sum N \le MM \le Score
1\rm 1 1010 2020 1010 55
2\rm 2 10210^2 2×1022 \times 10^2 10210^2 1010
3\rm 3 10310^3 2×1032 \times 10^3 10310^3 1515
4\rm 4 10510^5 2×1052 \times 10^5 10510^5 2525
5\rm 5 2×1062 \times 10^6 4545

Note

The input size of this problem is large. Please use a fast input method.

Translated by ChatGPT 5