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<bits/stdc++.h>
using namespace std;
struct edge{
    int y,c,w;
    edge(){y=c=w=0;}
    edge(int _y,int _c,int _w){y=_y;c=_c;w=_w;}
};
int n;
vector<edge> g[100005];
int dep[100005];
int fa[100005][17];
void dfs4lca(int x,int p,int cd){
    fa[x][0]=p;
    dep[x]=cd;
    for(edge &e:g[x])if(e.y!=p){
        dfs4lca(e.y,x,cd+1);
    }
}
void init4lca(){
    dfs4lca(1,-1,0);
    for(int j=0;j<16;j++){
        for(int i=1;i<=n;i++){
            if(fa[i][j]==-1)fa[i][j+1]=-1;
            else fa[i][j+1]=fa[fa[i][j]][j];
        }
    }
}
int lca(int x,int y){
    if(dep[x]<dep[y])swap(x,y);
    for(int i=16;i>=0;i--){
        if(fa[x][i]!=-1&&dep[fa[x][i]]>=dep[y])x=fa[x][i];
    }
    if(x==y)return x;
    for(int i=16;i>=0;i--){
        if(fa[x][i]!=fa[y][i]){
            x=fa[x][i];
            y=fa[y][i];
        }
    }
    return fa[x][0];
}
struct query{
    int id,x,y;
    query(int _id=-1,int _x=-1,int _y=-1){
        id=_id;x=_x;y=_y;
    }
};
vector<query> qs[100005];
int sum[100005],cnt[100005],ans[300005];
void dfs(int x,int p,int d){
    for(query q:qs[x]){
        ans[q.id]=d+cnt[q.x]*q.y-sum[q.x];
    }
    for(edge e:g[x])if(e.y!=p){
        sum[e.c]+=e.w;
        cnt[e.c]++;
        dfs(e.y,x,d+e.w);
        sum[e.c]-=e.w;
        cnt[e.c]--;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int q;
    cin>>n>>q;
    for(int i=1;i<n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        g[a].push_back(edge(b,c,d));
        g[b].push_back(edge(a,c,d));
    }
    init4lca();
    for(int i=1;i<=q;i++){
        int x,y,u,v,anc;
        cin>>x>>y>>u>>v;
        anc=lca(u,v);
        qs[anc].push_back(query(i,x,y));
        qs[u].push_back(query(i+q,x,y));
        qs[v].push_back(query(i+q+q,x,y));
    }
    dfs(1,-1,0);
    for(int i=1;i<=q;i++){
        cout<<-ans[i]-ans[i]+ans[i+q]+ans[i+q+q]<<endl;
    }
    return 0;
}