/*
勉強させて頂きました。ありがとうございます。
I learn with this link.
https://betrue12.hateblo.jp/entry/2019/07/08/000306
https://atcoder.jp/contests/abc133/submissions/6301894
 */

#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const int infi = 2147483647;
const ll infl = 1e17;

struct LCA{
    static const int MAX_log = 30;
    vector<int> parent[MAX_log];
    vector<int> depth;
    int logn;

    void __init__(int N,const vector<int> edges[]){
        while ((1<<logn)<N)
            logn++;
        rep(i, logn) parent[i].resize(N,-1);
        depth.resize(N, -1);
        dfs(0, -1,0, edges);
        rep(k,logn-1){
            rep(v,N){
                if (parent[k][v]<0){
                    parent[k + 1][v] = -1;
                }
                else{
                    parent[k + 1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }
    void dfs(int now,int p,int d,const vector<int> edges[]){
        parent[0][now] = p;
        depth[now] = d;
        for(auto nex:edges[now]){
            if(nex!=p){
                dfs(nex, now, d + 1, edges);
            }
        }
    }
    int calc_lca(int u,int v){
        if (depth[u]>depth[v])
            swap(u, v);
        rep(k,logn){
            if(((depth[v]-depth[u])>>k) &1){
                v = parent[k][v];
            }
        }
        if (u==v)
            return u;
        for (int k = logn - 1; k >= 0;k--){
            if (parent[k][u]!=parent[k][v]){
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

    int calc_depth(int u,int v){
        int l = calc_lca(u, v);
        return depth[u] + depth[v] - 2 * depth[l];
    }
};

int N, Q;
vector<vector<int>> edges[100005];
vector<int> lcaedges[100005];
map<int, int> all_num[100005], all_sum[100005];
int dist[100005],now_num[100005], now_sum[100005];
vector<int> need_col[100005];

void dfs(int now,int p){
    for(auto c:need_col[now]){
        all_sum[now][c] = now_sum[c];
        all_num[now][c] = now_num[c];
    }
    for (auto& e:edges[now]){
        int nex = e[0], c = e[1], d = e[2];
        if(nex!=p){
            dist[nex] = dist[now] + d;
            now_sum[c] += d;
            now_num[c]++;
            dfs(nex, now);
            now_sum[c] -= d;
            now_num[c]--;
        }
    }
}
int main()
{
    cin >> N >> Q;
    rep(i,N-1){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        c--;
        edges[a].push_back({b, c, d});
        edges[b].push_back({a, c, d});
        lcaedges[a].push_back(b);
        lcaedges[b].push_back(a);
    }
    LCA lca;
    lca.__init__(N, lcaedges);
    int X[100005], Y[100005], U[100005], V[100005],L[100005];
    rep(i,Q){
        cin>>X[i]>>Y[i]>>U[i]>>V[i];
        X[i]--;
        U[i]--;
        V[i]--;
        L[i] = lca.calc_lca(U[i], V[i]);
        need_col[U[i]].push_back(X[i]);
        need_col[V[i]].push_back(X[i]);
        need_col[L[i]].push_back(X[i]);
    }
    dfs(0, -1);
    rep(i,Q){
        int u = U[i], v = V[i], l = L[i],x=X[i],y=Y[i];
        int du = dist[u] - all_sum[u][x] + y * all_num[u][x];
        int dv = dist[v] - all_sum[v][x] + y * all_num[v][x];
        int dl = dist[l] - all_sum[l][x] + y * all_num[l][x];
        cout << du + dv - 2 * dl << endl;
    }
}


Measured memory_bytes: 73268