Cossack Vus and the Tree
Kozak Vus encountered a tree on his way home from the railway station and devised an intriguing problem.
Consider a tree with vertices, where each edge has a specific weight. Initially, all vertices are colored white. An edge is termed "bright" if it connects two white vertices. You need to answer queries, each asking:
What is the minimum number of vertices that must be repainted black so that the total weight of all bright edges does not exceed ?
Assist Kozak Vus in solving this problem.
Input
The first line contains three integers , , and (, , ) — representing the number of vertices, the number of queries, and the block number, respectively.
Each of the following lines contains three integers , , (, ) — indicating the vertices connected by the edge and its weight.
The fourth line contains integers ().
Output
Output integers , where is the answer to the -th query.
Examples
Note
In the first example, if , all vertices can remain white, making all edges bright with a total weight of . For , painting vertex number black results in no bright edges, thus the total weight is . In both scenarios, the sum of the weights of the bright edges does not exceed , and the minimum number of vertices is repainted.
Scoring
( points): ; it is guaranteed that the answer does not exceed .
( points): ; it is guaranteed that the answer does not exceed .
( points): ; .
( points): ; ;
( points): ;
( points): no additional constraints.