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;
typedef long long ll;

// LCA
vector<vector<array<int,3>>> v(100010);
int depth[100010];
int par[100010][20];

// 根からの深さと1つ上の親を求める. initの中で使う
void dfs2(int p,int d,int pre){
    depth[p] = d;
    for(auto e:v[p]){
        int i=e[0], c=e[1], di=e[2];
        if(i!=pre){
            dfs2(i,d+1,p);
            par[i][0] = p;
        }
    }
}

// init(n, root) でダブリングテーブルを作製する, nは頂点数
void init(int n,int root=0){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            par[i][j] = -1;
        }
    }
    dfs2(root,0,-1);
    for(int j=1;j<20;j++){
        for(int i=0;i<n;i++){
            if(par[i][j-1] == -1) continue;
            par[i][j] = par[par[i][j-1]][j-1];
        }
    }
}

//頂点aのd個上の親を求める
ll get_nyaa(ll a,ll d){
    for(ll i=19;i>=0;i--){
        if(d & (1<<i)) a = par[a][i];
    }
    return a;
}

// a,bのLCAを求める
int lca(int a,int b){
    if(depth[a] < depth[b]) swap(a,b);
    int dif = depth[a] - depth[b];
    for(int i=19;i>=0;i--){
        if(dif & (1<<i)) a = par[a][i];
    }
    if(a==b) return a;
    for(int i=19;i>=0;i--){
        if(par[a][i]!=par[b][i]){
            a = par[a][i], b = par[b][i];
        }
    }
    return par[a][0];
}

ll dist[100020];
int cnt[100010];
ll dc[100010];
map<int,int> col[100010];
map<int,ll> dcol[100010];

void dfs(int p,int d,int pre){
    dist[p]=d;
    for(auto e:v[p]){
        int i=e[0],c=e[1],di=e[2];
        if(i != pre){
            cnt[c]++;
            dc[c] += di;
            for(auto &k:col[i]){
                k.second = cnt[k.first];
                dcol[i][k.first] = dc[k.first];
            }
            dfs(i,d+di,p);
            cnt[c]--;
            dc[c] -= di;
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--,b--;
        v[a].push_back({b,c,d});
        v[b].push_back({a,c,d});
    }
    init(n,0);
    array<int,5> a[q];
    for(int i=0;i<q;i++){
        int c,d,x,y;
        cin>>c>>d>>x>>y;
        x--,y--;
        int l = lca(x,y);
        a[i] = {c,d,x,y,l};
        col[x][c]=0;
        col[y][c]=0;
        col[l][c]=0;
    }
    dfs(0,0,-1);
    for(int i=0;i<q;i++){
        int x=a[i][2],y=a[i][3],l=a[i][4];
        ll c=a[i][0],d=a[i][1];
        ll ans = dist[x]+dist[y]-2*dist[l] + (col[x][c]+col[y][c]-2*col[l][c])*d;
        ans -= dcol[x][c] + dcol[y][c] - 2*dcol[l][c];
        cout << ans << "\n";
    }


    
}