Territory Game

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

문제

Alice and Bob like to play games on a tree with nn vertices conveniently labeled with 1,2,,n1, 2, \dots, n. They play a total of qq games.

In game ii, Alice starts at vertex a_ia\_i while Bob starts at a different vertex b_ib\_i. Initially, all vertices have no color except for the vertices a_ia\_i and b_ib\_i: vertex a_ia\_i is colored by Alice while vertex b_ib\_i is colored by Bob.

After that, the players take turns for k_ik\_i moves in total: Alice moves first, Bob moves second, then Alice makes the third move, and so on. In each move, the respective player moves to an adjacent vertex and colors it. Note that a vertex can be recolored: at any moment, each colored vertex has the color of the player who arrived there most recently.

Let the final number of vertices of Alice's color be AA, and the final number of vertices of Bob's color be BB. Alice would like to maximize the number (AB)(A - B), while Bob would like to minimize this number.

For each game, find the difference (AB)(A - B) if both players play optimally.

입력

The input contains zero or more test cases, and is terminated by end-of-file. For each test case:

The first line contains two integers nn and qq (2n21052 \leq n \leq 2 \cdot 10^5, 1q21051 \leq q \leq 2 \cdot 10^5).

The ii-th of the following (n1)(n - 1) lines contains two integers u_iu\_i and v_iv\_i which denote an edge between vertices u_iu\_i and v_iv\_i (1u_i,v_in1 \leq u\_i, v\_i \leq n). It is guaranteed that the input forms a tree.

The ii-th of the last qq lines contains three integers a_ia\_i, b_ib\_i and k_ik\_i (1a_i,b_in1 \leq a\_i, b\_i \leq n, 1k_i2n1 \leq k\_i \leq 2 n, a_ib_ia\_i \neq b\_i). It is guaranteed that both the sum of all nn and the sum of all qq do not exceed 21052 \cdot 10^5.

출력

For each test case, output an integer which denotes the difference.