#abc133f. [abc133_f]Colorful Tree

[abc133_f]Colorful Tree

Problem Statement

There is a tree with NN vertices numbered 11 to NN. The ii-th edge in this tree connects Vertex aia_i and Vertex bib_i, and the color and length of that edge are cic_i and did_i, respectively. Here the color of each edge is represented by an integer between 11 and N1N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.

Answer the following QQ queries:

  • Query jj (1leqjleqQ1 \\leq j \\leq Q): assuming that the length of every edge whose color is xjx_j is changed to yjy_j, find the distance between Vertex uju_j and Vertex vjv_j. (The changes of the lengths of edges do not affect the subsequent queries.)

Constraints

  • 2leqNleq1052 \\leq N \\leq 10^5
  • 1leqQleq1051 \\leq Q \\leq 10^5
  • 1leqai,bileqN1 \\leq a_i, b_i \\leq N
  • 1leqcileqN11 \\leq c_i \\leq N-1
  • 1leqdileq1041 \\leq d_i \\leq 10^4
  • 1leqxjleqN11 \\leq x_j \\leq N-1
  • 1leqyjleq1041 \\leq y_j \\leq 10^4
  • 1lequj<vjleqN1 \\leq u_j < v_j \\leq N
  • The given graph is a tree.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ a1a_1 b1b_1 c1c_1 d1d_1 :: aN1a_{N-1} bN1b_{N-1} cN1c_{N-1} dN1d_{N-1} x1x_1 y1y_1 u1u_1 v1v_1 :: xQx_Q yQy_Q uQu_Q vQv_Q

Output

Print QQ lines. The jj-th line (1leqjleqQ1 \\leq j \\leq Q) should contain the answer to Query jj.


Sample Input 1

5 3
1 2 1 10
1 3 2 20
2 4 4 30
5 2 1 40
1 100 1 4
1 100 1 5
3 1000 3 4

Sample Output 1

130
200
60

The graph in this input is as follows:

Figure

Here the edges of Color 11 are shown as solid red lines, the edge of Color 22 is shown as a bold green line, and the edge of Color 44 is shown as a blue dashed line.

  • Query 11: Assuming that the length of every edge whose color is 11 is changed to 100100, the distance between Vertex 11 and Vertex 44 is 100+30=130100 + 30 = 130.
  • Query 22: Assuming that the length of every edge whose color is 11 is changed to 100100, the distance between Vertex 11 and Vertex 55 is 100+100=200100 + 100 = 200.
  • Query 33: Assuming that the length of every edge whose color is 33 is changed to 10001000 (there is no such edge), the distance between Vertex 33 and Vertex 44 is 20+10+30=6020 + 10 + 30 = 60. Note that the edges of Color 11 now have their original lengths.