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 laps (lap means a portion of a trip). However, the racing track is different from F5 racing. The T5 racing track has checkpoints and each checkpoint has score point 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 laps.
A driver can add score point to his/her to her scorecard when he/she enters checkpoint 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 starts with an integer (), denoting the number of test cases. Each case starts with two integers () and () as mentioned above. Next line contains integers separated by space and the -th integer of this line represents the score point () of the -th checkpoint. Next lines will contain two integers and , meaning that there is a racing road between checkpoint and .
For each case, print the case number and the maximum score point your team driver needs to win the race in a line.
Input | Output |
---|---|
1 4 2 1 4 2 3 1 2 1 3 3 4 | Case 1: 6 |