시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 0 0 0 0.000%

## 문제

Sam is working as a truck driver and is frequently delivering goods between various warehouses. There are N warehouses in total. Some warehouses are connected, and there is exactly one way to get from each warehouse to each other warehouse, possibly passing several other warehouses along the way.

To make his trips, Sam will be using various battery-powered trucks. Each truck has a folding solar panel that can be used to charge the battery, but only when the truck is stopped. While traveling from one warehouse to another, Sam can stop at any point and wait a bit to recharge the battery. When the battery is out of charge, he can’t move. Sam must also stop at every warehouse he passes through for security reasons. When he stops at a warehouse, he can also recharge the battery.

Sam doesn’t like to stop too much, so he asked you to find the smallest number of stops for each route he takes. This includes both stops made for recharging and stops at warehouses, including the starting and final warehouses (for loading and unloading).

## 입력

The first line contains two numbers N and Q, the number of warehouses and the number of routes Sam takes, with 1 ≤ N, Q ≤ 100, 000. The next N − 1 lines describe roads between warehouses. Each line contains 3 numbers: U, V, D. U and V are indices of warehouses, with 1 ≤ U, V ≤ N. D is the length of the road between warehouses U and V in kilometres, with 1 ≤ D ≤ 20, 000. The next Q lines describe the routes Sam takes. Each line contains 3 numbers: S, F, T. S and F are indices of the starting and final warehouses on the route, with 1 ≤ S, F ≤ N and S 6= F. T is the capacity of the battery of the truck used for this route, expressed as the distance that the truck can travel on a full charge (in kilometres). T satisfies 1 ≤ T ≤ 20, 000.

## 출력

For each of the Q routes, output one line containing the smallest number of stops that need to be made along the route.

7 5
1 2 1
2 3 2
2 4 3
4 5 4
4 6 5
4 7 6
3 7 2
2 6 1
5 7 3
1 4 1
3 7 1

7
9
5
5
12

4 3
1 2 5
2 3 10
3 4 20
1 4 20
1 4 10
1 4 5

4
5
8