#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
struct wedge {
    int u, v, c, d;
    wedge reverse() const { return {v, u, c, d}; }
};
template <bool Directed, typename TEdge> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + 1) {}
    graph(int n, int m) : graph(n) { edges.reserve(m); }
    TEdge& operator()(int i) { return edges[i]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - 1; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
template <typename graph> void dfs(graph& g,
const function<void(int)>& pre_root = [](int) {},
const function<void(typename graph::EType&)>& pre = [](typename graph::EType&) {},
const function<void(typename graph::EType&)>& pos = [](typename graph::EType&) {},
const function<void(int)>& pos_root = [](int) {},
int root = 0) {
    vector<bool> vis(g.size() + 1);
    function<void(int)> dfs = [&](int u) {
        vis[u] = true;
        for(int i : g[u]) if(not vis[g(i).v]) {
            pre(g(i));
            dfs(g(i).v);
            pos(g(i));
        }
    };
    if(root) {
        pre_root(root), dfs(root), pos_root(root);
    } else {
        for(int u = 1; u <= g.size(); u++) if(not vis[u]) {
            pre_root(u), dfs(u), pos_root(u);
        }
    }
}
constexpr int lg(int x) { return x ? 31 - __builtin_clz(x) : 0; }
template <typename TEdge> struct binary_lift {
    vector<int> depth;
    vector<vector<int>> p;
    binary_lift(graph<0, TEdge>& g) : depth(g.size() + 1), p(g.size() + 1) {
        dfs(g, [](int) {}, [&](TEdge& e) {
            p[e.v].push_back(e.u);
            depth[e.v] = depth[e.u] + 1;
            build_ancestors(e.v);
        });
    }
    void build_ancestors(int u) {
        for(int pow2 = 1; pow2 <= lg(depth[u]); pow2++) {
            p[u].push_back(p[p[u][pow2 - 1]][pow2 - 1]);
        }
    }
    int kth_ancestor(int u, int k) {
        return k == 0 ? u : kth_ancestor(p[u][lg(k & -k)], k - (k & -k));
    }
    int lca(int u, int v) {
        if(depth[u] > depth[v]) swap(u, v);
        v = kth_ancestor(v, depth[v] - depth[u]);
        for(int pow2 = lg(depth[u]); pow2 >= 0; pow2--) {
            if((1 << pow2) <= depth[u] and p[u][pow2] != p[v][pow2]) {
                u = p[u][pow2], v = p[v][pow2];
            }
        }
        return u == v ? u : p[u][0];
    }
    int dist(int u, int v) {
        return depth[u] + depth[v] - 2 * depth[lca(u, v)];
    }
};
struct query {
    int i, x, y, m;
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    graph<0, wedge> g(n);
    for(int i = 1; i < n; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        g.add_edge({a, b, c, d});
    }
    binary_lift<wedge> bl(g);
    vector<vector<query>> queries(n + 1);
    for(int i = 0; i < q; i++) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        queries[u].push_back({i, x, y, 1});
        queries[v].push_back({i, x, y, 1});
        queries[bl.lca(u, v)].push_back({i, x, y, -2});
    }
    ll s = 0;
    vector<ll> s_color(n);
    vector<ll> n_color(n);
    vector<int> ans(q);
    auto answer_queries = [&](int u) {
        for(query& q : queries[u]) {
            ans[q.i] += (s - s_color[q.x] + n_color[q.x] * q.y) * q.m;
        }
    };
    dfs(g, [&](int root) {
        answer_queries(root);
    }, [&](wedge& e) {
        s += e.d;
        s_color[e.c] += e.d;
        n_color[e.c]++;
        answer_queries(e.v);
    }, [&](wedge& e) {
        s -= e.d;
        s_color[e.c] -= e.d;
        n_color[e.c]--;
    });
    for(int x : ans) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 36588