#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 u, typename graph::EType* from) {},
const function<void(int, typename graph::EType*)>& pos = [](int u, typename graph::EType* from) {}) {
    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);
            }
        }
    }
}
struct binary_lift {
    vector<int> lg, depth;
    vector<vector<int>> p;
    binary_lift(graph<0, wedge>& g) : lg(g.n + 1), depth(g.n + 1), p(g.n + 1) {
        lg[0] = -1, lg[1] = 0;
        for(int i = 2; i <= g.n; i++) {
            lg[i] = lg[i / 2] + 1;
        }
        dfs(g, 1, [&](int u, wedge* from) {
            if(from) {
                p[u].push_back(from->u);
                depth[u] = depth[from->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 x, y, u, v;
};
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 bl(g);
    vector<query> queries(q);
    vector<set<int>> colors_of(n + 1);
    for(int i = 0; i < q; i++) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        queries[i] = {x, y, u, v};
        colors_of[u].insert(x);
        colors_of[v].insert(x);
        colors_of[bl.lca(u, v)].insert(x);
    }
    vector<ll> s(n + 1);
    vector<map<int, ll>> s_color(n);
    vector<map<int, ll>> n_color(n);
    vector<vector<int>> most_recent(n);
    dfs(g, 1, [&](int u, wedge* from) {
        if(from) {
            for(int c : colors_of[u]) {
                if(c != from->c) {
                    s_color[c][u] = most_recent[c].empty() ? 0 : s_color[c][most_recent[c].back()];
                    n_color[c][u] = most_recent[c].empty() ? 0 : n_color[c][most_recent[c].back()];
                }
            }
            s[u] = s[from->u] + from->d;
            s_color[from->c][u] = (most_recent[from->c].empty() ? 0 : s_color[from->c][most_recent[from->c].back()]) + from->d;
            n_color[from->c][u] = (most_recent[from->c].empty() ? 0 : n_color[from->c][most_recent[from->c].back()]) + 1;
            most_recent[from->c].push_back(u);
        }
    }, [&](int u, wedge* from) {
        if(from) {
            most_recent[from->c].pop_back();
        }
    });
    for(auto& qu : queries) {
        int x = qu.x, y = qu.y, u = qu.u, v = qu.v;
        cout << s[u] + s[v] - 2 * s[bl.lca(u, v)]
            - (s_color[x][u] + s_color[x][v] - 2 * s_color[x][bl.lca(u, v)])
            + (n_color[x][u] + n_color[x][v] - 2 * n_color[x][bl.lca(u, v)]) * y
        << endl;
    }
    return 0;
}


Measured memory_bytes: 93164