There is a tree with N vertices numbered 1 to N.
The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.
Here the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.
Answer the following Q queries:
 - Query j (1 \leq j \leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)

-----Constraints-----
 - 2 \leq N \leq 10^5
 - 1 \leq Q \leq 10^5
 - 1 \leq a_i, b_i \leq N
 - 1 \leq c_i \leq N-1
 - 1 \leq d_i \leq 10^4
 - 1 \leq x_j \leq N-1
 - 1 \leq y_j \leq 10^4
 - 1 \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:
N Q
a_1 b_1 c_1 d_1
:
a_{N-1} b_{N-1} c_{N-1} d_{N-1}
x_1 y_1 u_1 v_1
:
x_Q y_Q u_Q v_Q

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

-----Sample Input-----
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-----
130
200
60

The graph in this input is as follows:

Here the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.
 - Query 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.
 - Query 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.
 - Query 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# https://atcoder.jp/contests/abc133/submissions/6316420\n# 参考にさせていただきました。\n\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**5)\n\nn, q = map(int, input().split())\nedges = [[] for i in range(n)]\nfor i in range(n-1):\n    a,b,c,d = map(int, input().split())\n    a -= 1\n    b -= 1\n    c -= 1\n    edges[a].append((b,c,d))\n    edges[b].append((a,c,d))\n\n# ここで前処理\n# LCAができるようにしておく\ndep=[0]*n\npar=[[-1]*n for i in range(18)]\n# ついでに距離も持っておく\ndis=[0]*n\n\n# parent, now_point, depth, dist\n\ndef dfs(p,v,d,dd):\n    dep[v]=d\n    par[0][v]=p\n    dis[v]=dd\n    for w, _, dist in edges[v]:\n        if w!=p:\n            dfs(v,w,d+1, dd+dist)\n\ndef lca(a,b):\n    if dep[a]>dep[b]:\n        a,b=b,a\n    for i in range(18):\n        if (dep[b]-dep[a]) & 1<<i:\n            b=par[i][b]\n    if a==b:\n        return a\n    for i in range(18)[::-1]:\n        if par[i][a]!=par[i][b]:\n            a=par[i][a]\n            b=par[i][b]\n    return par[0][a]\n\ndfs(-1,0,0,0)\n\nfor i in range(17):\n    for j in range(n):\n        par[i+1][j]=par[i][par[i][j]]\n\n# LCAの準備が完了\n\nans = [0]*q\nv_need = [[] for i in range(n)]\nfor i in range(q):\n    x,y,u,v = map(int, input().split())\n    x -= 1\n    u -= 1\n    v -= 1\n    l = lca(u, v)\n    # 色の情報がほしいのは u, v, lの3点\n    # どのクエリに属するか, どの色を変えるか、距離はいくつにするか, 係数\n    v_need[u].append((i, x, y, 1))\n    v_need[v].append((i, x, y, 1))\n    v_need[l].append((i, x, y, -2))\n\n# 色が何回出たか\ncolor = [0]*n\n# その点までの各色の距離の総和\ncdist = [0]*n\n\ndef dfs2(cur, par):\n    for i, x, y, k in v_need[cur]:\n        ans[i] += k*(dis[cur] - cdist[x] + y*color[x])\n    for to, x, y, in edges[cur]:\n        if to == par:\n            continue\n        color[x] += 1\n        cdist[x] += y\n        dfs2(to, cur)\n        # オイラーツアーのように、戻ってきたら引く\n        # これによって、a→b→c→b→dと移動した時a→b→dとみなせる\n        color[x] -= 1\n        cdist[x] -= y\ndfs2(0, -1)\n\nfor i in ans:\n    print(i)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13993