409337: GYM103486 D Rush Morning
Description
Chiang loves cooking. There are N markets in her city. And there are N - 1 roads which make every market approachable from each other.
Chiang always goes to buy food in morning. Due to limited time in morning, she starts from one market, passes every market at most one time, and ends at another market. As a rich person, she would buy all the food on that path, and she wishes that the total cost of food on that path is the biggest among all the paths.
However, life is full of variety. Because of some reason, everyday there would be one road that the cost of food changes, and it would return to the original in the next morning. Now, Chiang wants to ask you to help her to calculate how much she would spent on food every day.
InputThe first line of input contains one integer N(2 ≤ N ≤ 2 × 105), indicating the number of markets in the city.
Each of the following N - 1 lines contains 3 integers u, v(1 ≤ u, v ≤ N, u ≠ v) and w(0 ≤ w ≤ 109), indicating the road between market u and market v and the cost of food on it w.
The next line contains one integer T(1 ≤ T ≤ 2 × 105), indicating the number of days Chiang asks for your help.
Then there are T lines following. The i-th line contains 3 integers u, v(1 ≤ u, v ≤ N, u ≠ v) and w(0 ≤ w ≤ 109), which means that the value of food on road from u to v changes to w in the i-th morning. It's guaranteed that the road exists.
OutputOutput T lines: the i-th lines contains an integer indicating the answer of how much Chiang would spend in the i-th morning.
ExamplesInput7 2 3 4 4 2 2 1 2 5 1 5 2 7 6 3 5 6 4 4 2 4 1 2 3 1 1 2 7 2 4 3Output
18 16 20 18Input
3 1 2 1 1 3 0 1 1 2 0Output
0