#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

struct SegmentTree
{
    using T = int;

    int N;
    vector<T> dat;

    T id = 0;
    T F(T &a, T &b) { return a + b; }
    
    SegmentTree(int n){
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<T>(2 * N - 1, id);
    }

    SegmentTree(int n, vector<T> &v){
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<T>(2 * N - 1, id);
        for(int i = 0; i < n; i++) dat[i + N - 1] = v[i];
        for(int i = N - 2; i >= 0; i--) dat[i] = F(dat[i * 2 + 1], dat[i * 2 + 2]); 
    }

    SegmentTree(){}


    void update(int k, T a){
        k += N - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = F(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    void reset() { fill(dat.begin(), dat.end(), id); }

    T get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return id;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(vl, vr);
        }
    }
    T get(int a, int b) { return get(a, b, 0, 0, N); }

    T val(int k){ return dat[k + N - 1]; }
};

struct SparseTable
{
    using T = Pii;
    vector<vector<T>> table;

    T F(T a, T b){
        return min(a, b);
    }
    
    SparseTable(int N){
        int n = 32 - __builtin_clz((signed)N);
        table = vector<vector<T>>(n, vector<T>(N));
    }

    SparseTable(int N, vector<T> &A){
        int n = 32 - __builtin_clz((signed)N);
        table = vector<vector<T>>(n, vector<T>(N));
        initialize(A);
    }

    SparseTable(){}

    void initialize(vector<T> &A){
        for(int i = 0; i < A.size(); i++) table[0][i] = A[i];
        for(int n = 0; n < table.size() - 1; n++){
            for(int i = 1 << n; i < A.size(); i++){
                table[n + 1][i - (1 << n)] = F(table[n][i - (1 << n)], table[n][i]);
            }
        }
    }

    // the range is [l, r]
    // 0 <= l <= r < N must be satisfied
    T get(int l, int r){
        int n = 31 - __builtin_clz((signed)(r - l + 1));
        return F(table[n][l], table[n][r - (1 << n) + 1]);
    }

};

struct edge{int to, cost, num;};

class Graph
{
public:
    int N;
    vector<vector<edge>> G;
    vec id, depth, cs;
    pairs vs;
    mat ls;
    SparseTable ST;
    SegmentTree Seg1, Seg2;

    Graph(int N): N(N){
        G = vector<vector<edge>>(N, vector<edge>(0));
        id = vec(N, -1);
        depth.resize(N);
        ls.resize(N - 1);
    }

    void add_Directed_edge(int from, int to, int cost, int num){
        G[from].push_back(edge({to, cost, num}));
    }

    void add_Undirected_edge(int v1, int v2, int cost, int num){
        add_Directed_edge(v1, v2, cost, num);
        add_Directed_edge(v2, v1, cost, num);
    }

    void dfs(int v, int p = -1, int c = -1, int n = -1){
        if(p == -1) depth[v] = 0;
        else depth[v] = depth[p] + 1;
        if(id[v] == -1) id[v] = SZ(vs);
        vs.pb(Pii(depth[v], v));
        if(p != -1){
            ls[n].pb(SZ(cs));
            cs.pb(c);
        }
        for(auto e: G[v]) if(e.to != p){
            dfs(e.to, v, e.cost, e.num);
            vs.pb(Pii(depth[v], v));
            ls[e.num].pb(SZ(cs));
            cs.pb(-e.cost);
        }

        if(p == -1){
            ST = SparseTable(SZ(vs), vs);
            Seg1 = SegmentTree(SZ(cs), cs);
            Seg2 = SegmentTree(SZ(cs));
        }
    }
    int lca(int s, int t){
        s = id[s], t = id[t];
        if(s > t) swap(s, t);
        return ST.get(s, t + 1).second;
    }

    void update(vec &c){
        for(int i: c){
            for(int j: ls[i]){
                Seg1.update(j, 0);
                if(cs[j] > 0) Seg2.update(j, 1);
                else Seg2.update(j, -1);
            }
        }
    }
    void reverse(vec &c){
        for(int i: c){
            for(int j: ls[i]){
                Seg1.update(j, cs[j]);
                Seg2.update(j, 0);
            }
        }
    }
    int calcans(int u, int v, int y){
        int a = lca(u, v);
        a = id[a], u = id[u], v = id[v];
        return Seg1.get(a, u) + Seg1.get(a, v) + y * (Seg2.get(a, u) + Seg2.get(a, v));
    }

};



signed main(){

    int N, Q; cin >> N >> Q;
    int a, b, c, d;
    mat ls(N - 1);
    Graph G(N);
    REP(i, N - 1){
        cin >> a >> b >> c >> d;
        G.add_Undirected_edge(a - 1, b - 1, d, i);
        ls[c - 1].pb(i);
    }
    G.dfs(0);
    
    vec x(Q), y(Q), u(Q), v(Q);
    mat qs(N - 1);
    vec ans(Q);
    REP(i, Q){
        cin >> x[i] >> y[i] >> u[i] >> v[i];
        x[i]--; u[i]--; v[i]--;
        qs[x[i]].pb(i);
    }

    /*
    REP(i, Q){
        G.update(ls[x[i]]);
        ans[i] = G.calcans(u[i], v[i], y[i]);
        G.reverse(ls[x[i]]);
    }*/
    REP(i, N - 1){
        G.update(ls[i]);
        for(int q: qs[i]) ans[q] = G.calcans(u[q], v[q], y[q]);
        G.reverse(ls[i]);
    }
    Out(ans);


    return 0;
}


Measured memory_bytes: 110516