Limits 2s, 512 MB

It is high time for the annual T5 racing and your team is planning to win the race. In T5 racing the drivers need to complete at most XX laps (lap means a portion of a trip). However, the racing track is different from F5 racing. The T5 racing track has NN checkpoints and each checkpoint ii has score point PiP_i associated with it. Checkpoints are connected by some bidirectional racing roads and there is no cycle in the T5 racing track.

For example, there are four checkpoints in the picture and three racing roads connecting them. The rules of the T5 racing are very simple. At any point of time, if a driver is at checkpoint 2, he/she can move to any of the directly connected checkpoint 1 or 3 to complete one lap. The race will start at checkpoint 1 and the drivers can finish the race at any checkpoint. Two drivers can take two different paths to finished the race as long as they complete at most XX laps.

A driver can add score point PiP_i to his/her to her scorecard when he/she enters checkpoint ii for the first time. Drivers can enter the same checkpoint multiple time during the race but they will get the score only the first time. The highest score scorer will win the race and there can be multiple winners.

Since you are the greatest T5 hacker on this Galaxy, and you already know the racing track map for the next race. Now you have to tell what is the maximum score your team driver needs to win the race.

Input

Input starts with an integer TT (0<T1000 < T ≤ 100), denoting the number of test cases. Each case starts with two integers NN (1N1001 ≤ N ≤ 100) and XX (1X2001 ≤ X ≤ 200) as mentioned above. Next line contains NN integers separated by space and the ii-th integer of this line represents the score point PiP_i (0Pi1050 ≤ P_i ≤ 10^5) of the ii-th checkpoint. Next N1N -1 lines will contain two integers ii and jj, meaning that there is a racing road between checkpoint ii and jj.

Output

For each case, print the case number and the maximum score point your team driver needs to win the race in a line.

Sample

InputOutput
1
4 2
1 4 2 3
1 2
1 3
3 4
Case 1: 6

Submit

Login to submit.

Contributors

Statistics

65% Solution Ratio
balmarEarliest, May '19
Kuddus.6068Fastest, 0.0s
shahed95Lightest, 131 kB
serotoninShortest, 1200B
Toph uses cookies. By continuing you agree to our Cookie Policy.