#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 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]);
    }

};

//0-indexed BIT
class BinaryIndexedTree
{
    using T = int;
private:
    void _add(int i, T x) {
        if (i > N) return;
        data[i] += x;
        _add(i + (i & -i), x);
    }

public:
    vector<T> data;
    int N;

    BinaryIndexedTree(int N): data(vector<T>(N + 1, 0)), N(N) {}
    BinaryIndexedTree(){}

    //sum of [0,i) (0<=i<=N)
    T sum(int i) {
        if (!i) return 0;
        return data[i] + sum(i - (i & -i));
    }

    void add(int i, T x) { _add(i + 1, x); };
    void update(int i, T x){
        T now = sum(i + 1) - sum(i);
        add(i, x - now);
    }

};

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

class Graph
{
public:
    int N;
    vector<vector<edge>> G;

    Graph(int N): N(N){
        G = vector<vector<edge>>(N, vector<edge>(0));
    }

    void add_Directed_edge(int from, int to, int cost = 1, int id = 0){
        G[from].push_back(edge({to, cost, id}));
    }

    void add_Undirected_edge(int v1, int v2, int cost = 1, int id = 0){
        add_Directed_edge(v1, v2, cost, id);
        add_Directed_edge(v2, v1, cost, id);
    }

    //オイラーツアー (SparseTableとBITをこれより前に貼る)
    //木であり、辺のidは0~N-1であると仮定
    vector<int> es, pos;
    vector<Pii> vs;
    vector<vector<int>> ls_p, ls_m;
    bool is_initialized = false;
    SparseTable ST;
    BinaryIndexedTree BIT;
    void euler_tour(int v = 0){
        vs.resize(0);
        es.resize(0);
        pos = vector<int>(N, -1);
        ls_p = vector<vector<int>>(N - 1, vector<int>(0));
        ls_m = vector<vector<int>>(N - 1, vector<int>(0));
        dfs_euler_tour(v);
        ST = SparseTable(vs.size(), vs);
        BIT = BinaryIndexedTree(es.size());
        REP(i, es.size()) BIT.add(i, es[i]);
        is_initialized = true;
    }

    void dfs_euler_tour(int v, int p = -1, int d = 0, int p_cost = 0, int p_id = -1){
        if(pos[v] == -1) pos[v] = vs.size();
        vs.push_back(Pii(d, v));
        if(p_id != -1){
            ls_p[p_id].push_back(es.size());
            es.push_back(p_cost);
        }
        for(auto e: G[v]) if(e.to != p){
            dfs_euler_tour(e.to, v, d + 1, e.cost, e.id);
            vs.push_back(Pii(d, v));
            ls_m[e.id].push_back(es.size());
            es.push_back(-e.cost);
        }
    }

    int lca(int a, int b){
        assert(is_initialized);
        a = pos[a], b = pos[b];
        if(a > b) swap(a, b);
        return ST.get(a, b).second;
    }
    int calcdist(int a, int b){
        assert(is_initialized);
        int c = lca(a, b);
        a = pos[a], b = pos[b], c = pos[c];
        return BIT.sum(a) + BIT.sum(b) - 2 * BIT.sum(c);
    }
    void update_cost(int i0, int x){
        for(int i: ls_p[i0]) BIT.update(i, x);
        for(int i: ls_m[i0]) BIT.update(i, -x);
    }

};

signed main(){

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

    vec ans(Q);
    REP(color, N - 1){
        for(int i: cls[color]){
            G.update_cost(i, 0);
            H.update_cost(i, 1);
        }

        for(int q: xls[color]) ans[q] = G.calcdist(u[q], v[q]) + y[q] * H.calcdist(u[q], v[q]);

        for(int i: cls[color]){
            G.update_cost(i, d[i]);
            H.update_cost(i, 0);
        }
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 185908