#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;
    int n;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : n(n), adj(n + 1) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    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, int root = 0,
const function<void(int, typename graph::EType*)>& pre = [](int, typename graph::EType*) {},
const function<void(int, typename graph::EType*)>& pos = [](int, typename graph::EType*) {}) {
    vector<bool> vis(g.n);
    function<void(int, typename graph::EType*)> dfs = [&](int u, typename graph::EType* from) {
        vis[u] = true;
        pre(u, from);
        for(int i : g.adj[u]) {
            int v = g.edges[i].v;
            if(not vis[v]) {
                dfs(v, &g.edges[i]);
            }
        }
        pos(u, from);
    };
    if(root) {
        dfs(root, nullptr);
    } else {
        for(int u = 1; u <= g.n; u++) {
            if(not vis[u]) {
                dfs(u, nullptr);
            }
        }
    }
}
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, int root = 1) : depth(g.n + 1), p(g.n + 1) {
        dfs(g, root, [&](int u, TEdge* from) {
            if(from) {
                p[u].push_back(from->u);
                depth[u] = depth[from->u] + 1;
                build_ancestors(u);
            }
        });
    }
    binary_lift(vector<int>& parent, vector<int>& topological_order) : depth(parent.size()), p(parent.size()) {
        for(int u : topological_order) {
            p[u].push_back(parent[u]);
            depth[u] = depth[parent[u]] + 1;
            build_ancestors(u);
        }
    }
    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];
    }
};
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);
    dfs(g, 1, [&](int u, wedge* from) {
        if(from) {
            s += from->d;
            s_color[from->c] += from->d;
            n_color[from->c]++;
        }
        for(query& q : queries[u]) {
            ans[q.i] += (s - s_color[q.x] + n_color[q.x] * q.y) * q.m;
        }
    }, [&](int u, wedge* from) {
        if(from) {
            s -= from->d;
            s_color[from->c] -= from->d;
            n_color[from->c]--;
        }
    });
    for(int x : ans) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 40556