In his spare time, Farmer John (FJ) has created a new video-sharing service, which he has named MooTube. On MooTube, Farmer John's cows can record, share, and discover many amusing videos. His cows have already posted videos, conveniently numbered from to . However, FJ cannot quite figure out how to help his cows find new videos they might like.
FJ wants to create a list of "suggested videos" for every MooTube video. This way, cows will be recommended the videos most relevant to the ones they have already watched.
FJ devises a metric of "relevance" which, as the name suggests, determines how relevant two videos are to each other. He picks n - 1 pairs of videos and manually computes the relevance of each pair. FJ then visualizes his videos as a network in which each video is a node, and the n - 1 pairs of videos he considered manually are connected by edges. Conveniently, FJ has chosen these n - 1 pairs so that any video can be reached from any other video along a path of connections in exactly one way. FJ decides that the relevance of any pair of videos is defined as the minimum relevance of the connections along this path.
Farmer John wants to pick a value such that, for any given MooTube video, all other videos with relevance at least to that video will be suggested. However, FJ is worried that too many videos will be suggested to his cows, which could distract them from milk production! Therefore, he wants to choose the value of carefully. Farmer John would like your help in answering a number of questions about the suggested videos for certain values of .
The first line contains two integers and q~(1 \le n \le 10^5, 1 \le q \le 10^5). Each of the next n - 1 lines describes a pair of videos that FJ compares manually. Each line contains three integers a_i, b_i and r_i~(1 \le a_i, b_i \le n, 1 \le r_i \le 10^9), indicating that videos a_i and b_i are connected with relevance r_i.
The next lines describe Farmer John's questions. Each line contains two integers k_i and v_i~(1 \le k_i \le 10^9, 1 \le v_i \le n), indicating that FJ's -th question asks how many videos will be suggested to viewers of video v_i if k = k_i.
Print lines. On the -th line, print the answer to FJ's -th question.
Example 1
Farmer John finds that videos and have relevance , videos and have relevance , and videos and have relevance . Based on this, videos and have relevance \min(3, 2) = 2, videos and have relevance \min(3, 4) = 3, and videos and have relevance \min(2, 4) = 2.
Farmer John wants to know how many videos will be suggested for video if k = 1, for video if k = 3, and for video if k = 4. With k = 1, videos , and will be suggested for video . With k = 3, videos and will be suggested for video . With k = 4, however, no videos will be suggested for video .