Cabins

Find the K-th smallest travel distance among all pairs of cabins placed on a weighted tree of river regions.

Hard8Binary searchDivide and conquerTreeNo attempts yetTime limit6sMemory limit64 MB

Problem

Subin and Jinyoung were camping by a mountain river when they found MM cabins. The river has NN regions. Region 1 sits at the lower course of the river, and the other regions sit at the middle or upper course. The MM cabins stand in MM different regions, one cabin per region. In the picture below, the regions painted gray are the ones with a cabin.

From every region except region 1, going down the river brings you to one other region, and the number of that region is always smaller than the number of the region you left. The current is weak, so going down the river takes the same time as going up it. The distance between two regions is the time it takes to travel along the river from one to the other.

A cabin is small, so Subin and Jinyoung cannot stay in the same one. They take two different cabins. While they get along they take the two closest cabins, but after a fight they have to move to the KK-th closest pair of cabins.

List every pair of two cabins in order of distance, from the smallest, and find the distance of the KK-th pair.

Input

The first line has the number of regions NN, the number of cabins MM, and the relationship value KK of Subin and Jinyoung.

Each of the next N1N-1 lines, for i=2,3,,Ni = 2, 3, \dots, N in this order, has the number RiR_i of the region you reach by going down the river from region ii, and the travel time DiD_i of that stretch.

The last line has the cabin positions C1,C2,,CMC_1, C_2, \dots, C_M in increasing order. Every cabin is in a different region.

2MN100,0002 \le M \le N \le 100{,}000, 1Ri<i1 \le R_i < i, 1Di10,0001 \le D_i \le 10{,}000, 1KM(M1)/21 \le K \le M(M-1)/2

Output

Print the distance of the KK-th closest pair of cabins.

Hint

If 3 pairs of cabins are at distance 2 and 2 pairs are at distance 5, then the answers for K=1,2,3,4,5K = 1, 2, 3, 4, 5 are 2, 2, 2, 5, 5 in that order.