Ants

아직 제출이 없습니다시간 제한5초메모리 제한256 MB

문제

In the Hundred Byte Wood, the ants have built nn anthills numbered 11 through nn. The anthills are connected by two-way tunnels so that there is exactly one simple path between each pair of the anthills.

Spring has come and the queen ant announced an annual rotation in the anthills structure. The rotation affects mm worker ants: the ii-th of them needs to leave its current anthill (labelled a_ia\_i) at time t_it\_i and proceed to the anthill labelled b_ib\_i using the shortest possible path. All the ants move with the same speed and none of them stop before reaching the destination.

The queen suspects that too many ants meeting at a single point can organize and start the secession. For each of the worker ants, the queen would like to know what is the largest number of travelling ants this worker will meet at a single point (either at some point of a tunnel or in one of the anthills). Note that meetings occur only during travel; that is, if the ii-th ant reaches the destination at time t_it'\_i, then ants ii and jj can meet each other only at time t\[t_i,t_i]\[t_j,t_j]t \in \[t\_i, t'\_i] \cap \[t\_j, t'\_j].

입력

The first line of the input contains two integers n,mn, m (1n,m100,0001 \leq n, m \leq 100\\,000) -- the number of the anthills and the count of worker ants affected by the rotation, respectively.

The following n1n - 1 rows contain the tunnel structure. Each of the rows contains three integers u_i,v_i,d_iu\_i, v\_i, d\_i (1u_i,v_in1 \leq u\_i, v\_i \leq n, u_iv_iu\_i \neq v\_i, 1d_i1091 \leq d\_i \leq 10^9) which indicate that the anthills u_iu\_i and v_iv\_i are connected by a two-way tunnel and a worker passes it in d_id\_i units of time.

The final mm rows describe the worker ants taking part in the rotation. Each of them contains three integers a_i,b_i,t_ia\_i, b\_i, t\_i (1a_i,b_in1 \leq a\_i, b\_i \leq n, a_ib_ia\_i \neq b\_i, 1t_i1091 \leq t\_i \leq 10^9) described in the task statement.

출력

You should output mm rows; the kk-th of them should contain the largest number of the travelling ants (other than kk) the kk-th ant will meet simultaneously.