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 CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define pb push_back
#define ii pair<int,int>
#define i3 pair<int, ii>
#define i5 pair<ii, i3>
#define p1 first
#define p2 second
#define _(i) (i&-i)
using namespace std;

const int N = 1e5+5;
int n,h[N],d[N],par[N],chain[N],top[N],w[N],ind[N];
vector<i3> ke[N];
vector<int> Cols[N];
ii bit[N];

int ans[N]; i5 qu[N];

ii operator + (ii a, ii b) { return ii(a.p1 + b.p1, a.p2 + b.p2); }
ii operator - (ii a, ii b) { return ii(a.p1 - b.p1, a.p2 - b.p2); }

void upd(int i, ii x)
{
    for(; i<=n; i+=_(i)) bit[i] = bit[i] + x;
}
ii get(int i)
{
    ii res = ii(0, 0);
    for(; i>0; i-=_(i)) res = res + bit[i];
    return res;
}
void dfs(int u)
{
    int v, z = 0;
    for(auto e: ke[u]) if (e.p1 != par[u]) {
        v = e.p1;
        Cols[e.p2.p1].pb(v);
        h[v] = h[u] +1; d[v] = e.p2.p2;

        par[v] = u; dfs(v);
        if (w[v] > w[z]) z = v;
    }
    chain[u] = z!=0 ? chain[z] : u;
    top[chain[u]] = u;
    w[u] = w[z] + 1;
}
void hld()
{
    int num = 0;
    for(int i=1; i<=n; ++i) if (chain[i] == i)
        for(int u=i; chain[u] == chain[i]; u = par[u])
            ind[u] = ++num;
}
ii lca(int u,int v)
{
    ii res = ii(0, 0);
    int s, t;
    while (chain[u] != chain[v]) {
        s = top[chain[u]];
        t = top[chain[v]];
        if (h[s] > h[t]) {
            res = res + get(ind[s]) - get(ind[u]-1);
            u = par[s];
        }else {
            res = res + get(ind[t]) - get(ind[v]-1);
            v = par[t];
        }
    }
    if (h[u] > h[v]) swap(u, v);
    return res + get(ind[u]-1) - get(ind[v]-1);
}
int main()
{
    //freopen("a.inp","r",stdin);
    int q;
    scanf("%d%d",&n,&q);
    for(int i=1; i<n; ++i) {
        int u, v, c, d;
        scanf("%d%d%d%d",&u,&v,&c,&d);
        ke[u].pb(i3(v, ii(c,d)));
        ke[v].pb(i3(u, ii(c,d)));
    }

    dfs(1); hld();
    for(int i=1; i<=n; ++i) upd(ind[i], ii(d[i], 0));

    for(int i=1; i<=q; ++i) {
        int x, y, u, v;
        scanf("%d%d%d%d",&x,&y,&u,&v);
        qu[i] = i5(ii(x, y), i3(i, ii(u, v)));
    }
    sort(qu+1, qu+1+q);

    for(int i=1; i<=q; ++i) {
        if (qu[i-1].p1.p1 != qu[i].p1.p1) {
            for(int u: Cols[qu[i-1].p1.p1]) upd(ind[u], ii(+d[u],-1));
            for(int u: Cols[qu[i  ].p1.p1]) upd(ind[u], ii(-d[u],+1));
        }
        auto tmp = lca(qu[i].p2.p2.p1, qu[i].p2.p2.p2);
        ans[qu[i].p2.p1] = tmp.p1 + tmp.p2 * qu[i].p1.p2;
    }
    for(int i=1; i<=q; ++i) printf("%d\n",ans[i]);
}