Problem: 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.

Example

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


Output

130
200
60

Solution (in PYTHON3):

Solution:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
D = N.bit_length()

edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append((b, c, d))
    edge[b].append((a, c, d))
query = tuple(tuple(map(int, input().split())) for _ in range(Q))

par = [[-1] * N for _ in range(D)]
dep = [0] * N
dist = [0] * N
node = [0]
while node:
    s = node.pop()
    for t, _, d in edge[s]:
        if par[0][s] == t:
            continue
        par[0][t] = s
        dep[t] = dep[s] + 1
        dist[t] = dist[s] + d
        node.append(t)

for d in range(D - 1):
    for i in range(N):
        par[d + 1][i] = par[d][par[d][i]]


def LCA(x, y):
    if dep[x] < dep[y]:
        x, y = y, x
    h = dep[x] - dep[y]
    for d in reversed(range(D)):
        if h >= 1 << d:
            x = par[d][x]
            h -= 1 << d
    if x == y:
        return x
    for d in reversed(range(D)):
        if par[d][x] != par[d][y]:
            x = par[d][x]
            y = par[d][y]
    return par[0][x]


memo = [[] for _ in range(N)]
ans = [0] * Q

for i, (x, y, u, v) in enumerate(query):
    u -= 1
    v -= 1
    c = LCA(u, v)
    ans[i] = dist[u] + dist[v] - 2 * dist[c]
    memo[u].append((x, y, i))
    memo[v].append((x, y, i))
    memo[c].append((x, y, ~i))


c_len = [0] * (N + 1)
c_cnt = [0] * (N + 1)


def dfs(s, p=-1):
    for c, val, i in memo[s]:
        if i >= 0:
            ans[i] -= c_len[c]
            ans[i] += c_cnt[c] * val
        else:
            ans[~i] += c_len[c] * 2
            ans[~i] -= c_cnt[c] * val * 2
    for t, c, d in edge[s]:
        if t == p:
            continue
        c_len[c] += d
        c_cnt[c] += 1
        dfs(t, s)
        c_len[c] -= d
        c_cnt[c] -= 1


dfs(0)
print(*ans, sep="\n")