P14018 [HackerEarth] The link to the Russian translation.
提高-
题目描述

The link to the Russian translation.

Enzo is trying to reach Bonnie in her dream. Bonnie's dreamland is so big. It has n cities and n-1 roads. One can go from any city to any other city using only these roads. So, it means there's a unique shortest path between any two cities. Each road has an integer length.

For a sequence of integers a1, a2, ..., ak, sum(l, r) = al + al+1 + ... + ar-1 (1 ≤ l ≤ r ≤ k+1, so by definition sum(x, x) = 0).

prettiness(al + al+1 + ... + ar-1) = max(sum(l, r)) for 1 ≤ l ≤ r ≤ k+1.

Enzo is too mysterious and curious, he has q questions (for what, we don't know). You're his only programmer friend, so he asks you the questions. In each question he gives you v and u and you should tell him the value of goodness(v, u) which can be calculated as follows: suppose e1, e2, ..., ek are the roads on the shortest path from v to u , in order we see them when we go from v to u (if v = u, then k = 0). goodness(v, u) = prettiness(length(e1), length(e2), ..., length(ek)).

Input
The first line of input contains two integers n and q (1 ≤ n, q ≤ 10^5).

The next n-1 lines contain the roads. Each line contains 3 integers v, u, w meaning there is a road between v and u with length equal to w (1 ≤ v, u ≤ n, v ≠ u, |w| ≤ 10^9).

The next q lines contain the questions. Each contains two integers v and u (1 ≤ v, u ≤ n).

Output
Print the answer to each question in one line.

SAMPLE INPUT
7 10
1 2 -4
5 4 -2
5 1 10
2 7 8
3 6 7
7 6 9
7 1
1 2
4 3
5 5
3 4
5 7
7 5
1 1
3 7
1 6

SAMPLE OUTPUT
8
0
30
0
30
14
14
0
16
17

输入格式

见题面

输出格式

见题面

样例输入
17 25 16 15 -793310687 8 9 920941026 12 7 176232961 6 4 799208132 14 2 -96619161 17 15 -178890005 8 6 59441129 13 1 -731711569 10 3 400640569 15 5 -867137989 1 2 -343270028 14 5 597687625 11 6 767821673 14 12 965190655 14 6 731558226 3 11 246162930 5 11 6 5 14 2 1 16 13 7 2 7 16 2 10 12 8 3 3 3 13 9 4 14 14 14 17 5 11 9 5 11 4 4 2 15 2 2 4 10 5 2 12 9 6 17 8 8 4 12
样例输出
2097067524 1329245851 0 597687625 1141423616 1141423616 597687625 3111374053 1073425732 0 1711940381 1530766358 0 0 1748203828 2097067524 0 597687625 0 2213833304 597687625 2677131036 1329245851 0 2495957013