Task
You are given a tree with nodes, labeled from to , where each edge has an integer weight. We define the distance between nodes and as the sum of weights on the unique simple path that connects them.
You are also given queries of the form , where you have to determine the shortest distance between node and any node between and , inclusive.
Input data
The first line of stdin contains two space-separated integers, and .
Each of the next lines of stdin contains three space-separated integers, , and , representing a weighted edge connecting nodes and with weight .
Each of the next lines of stdin contains three space-separated integers, , and , representing a query, as described above.
Output data
Each of the next lines of stdout will contain an integer , representing the shortest distance to any node between and , inclusive.
Constraints and clarifications
- ;
- ;
- ;
| # | Score | Constraints |
|---|---|---|
| 1 | 15 | |
| 2 | 12 | |
| 3 | 13 | |
| 4 | 20 | , the tree is a path |
| 5 | 15 | |
| 6 | 25 | No further restrictions. |
Example 1
stdin
5 3
1 2 10
2 3 10
3 4 10
4 5 10
1 3 5
3 1 2
2 4 5
stdout
20
10
20
Explanation
In the first sample case, the solutions are nodes , and for each of the queries.

Example 2
stdin
6 3
1 2 5
1 3 10
1 4 2
1 5 8
1 6 3
2 4 6
4 2 3
3 5 6
stdout
7
7
13
Explanation
In the second sample case, the solutions are nodes , and for each of the queries.

Example 3
stdin
3 1
1 2 5
1 3 5
1 2 3
stdout
5
Explanation
In the third sample case, the solution is node .
