Alpine valley
In an Alpine valley there are n villages (numbered 1 ... n) connected by only n - 1 roads. While it is still possible to get from any village to any other village, this might take quite some time. This gets particularly annoying if you have to buy basic supplies, as there is a shop in only s of the n villages.
This winter the situation got even worse due to heavy snowfall. It would therefore be advisable to either leave the valley, i.e. get to the only village E at the mountain pass connecting the valley to the outside world, or at least buy enough supplies for the next months. You overheard on the radio this morning that the snow has rendered one of the n - 1 roads unusable - however, you couldn't clearly understand which one.
You now want to know whether you and your friends can leave the valley and, if not, how far each of you has to drive at least to get to a village with a shop. As you are not sure yet which road is blocked and as your friends live in different villages across the valley, you should write a program that answers this question for q given combinations of village and blocked road.
Input
The first line contains the integers n (1 ≤ n ≤ 10^5
), s, q (1 ≤ q ≤ 10^5
) and e, where n is the number of villages, s (1 ≤ s ≤ n) is the number of shops, q is the number of queries to your program, and e (1 ≤ e ≤ n) is the village you have to reach in order to leave the valley.
Each of the following n - 1 lines consists of three integers a, b and w. This means that there is a road of length w (1 ≤ w ≤ 10^9
) connecting villages a and b (1 ≤ a ≤ n, 1 ≤ b ≤ n).
Then s lines follow, each consisting of a single integer c, meaning that there is a shop in village c (1 ≤ c ≤ n). Note that all of these lines are different, i.e. there is never more than one shop in a village.
Finally, there are q lines, each containing two integers i and r, meaning that the i-th road from the input (1 ≤ i < n, numbered in the order they are listed) is no longer usable and you want to know if your friends in village r (1 ≤ r ≤ n) can leave the valley and if not, how far the closest village with a shop is.
Output
Your output should consist of q lines. The i-th line should contain the answer to the i-th query from the input. More precisely, the respective line should contain the string "escaped" (without quotes) if it is possible to leave the valley; if not, then it should contain the distance to the closest village with a shop, or the string "oo" if no shop is reachable anymore.
Hint
The figure depicts the situation before a road becomes unusable. The villages with shops have been shaded in grey. The roads are labeled with "index / length". Exit from the valley is in village 1.