#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <class T>
struct tree {
    struct edge {
        int from;
        int to;
        int col;
        T cost;
    };

    vector<edge> edges;
    vector<vector<int>> g;
    int n;
    vector<int> pv;
    vector<int> pe;
    vector<int> sz;
    vector<int> depth;
    vector<int> order;
    vector<int> pos;
    vector<int> end;
    vector<T> dist;

    tree(int _n) : n(_n) {
        g.resize(n);
        pv.assign(n, -1);
        pe.assign(n, -1);
        sz.assign(n, 0);
        depth.assign(n, -1);
        pos.assign(n, -1);
        end.assign(n, -1);
        dist.resize(n);
    }
    int add(int from, int to, int col, T cost = 1) {
        int id = (int)edges.size();
        g[from].emplace_back(id);
        g[to].emplace_back(id);
        edges.push_back({from, to, col, cost});
        return id;
    }
    void do_dfs(int v) {
        pos[v] = (int)order.size();
        order.push_back(v);
        sz[v] = 1;
        for (int id : g[v]) {
            if (id == pe[v]) {
                continue;
            }
            edge e = edges[id];
            int to = e.from ^ e.to ^ v;
            depth[to] = depth[v] + 1;
            dist[to] = dist[v] + e.cost;
            pv[to] = v;
            pe[to] = id;
            do_dfs(to);
            sz[v] += sz[to];
        }
        end[v] = (int)order.size() - 1;
    }
    void do_dfs_from(int v) {
        depth[v] = 0;
        dist[v] = 0;
        pv[v] = pe[v] = -1;
        do_dfs(v);
    }

    int h;
    vector<vector<int>> p;
    inline void build_lca() {
        int mxd = *max_element(depth.begin(), depth.end());
        h = 1;
        while ((1 << h) <= mxd) {
            h++;
        }
        p.assign(n, vector<int>(h));
        for (int i = 0; i < n; i++) {
            p[i][0] = pv[i];
        }
        for (int j = 1; j < h; j++) {
            for (int i = 0; i < n; i++) {
                p[i][j] = (p[i][j - 1] == -1 ? -1 : p[p[i][j - 1]][j - 1]);
            }
        }
    }
    inline bool anc(int x, int y) {
        return (pos[x] <= pos[y] && end[y] <= end[x]);
    }
    inline int lca(int x, int y) {
        if (anc(x, y)) {
            return x;
        }
        if (anc(y, x)) {
            return y;
        }
        for (int j = h - 1; j >= 0; j--) {
            if (p[x][j] != -1 && !anc(p[x][j], y)) {
                x = p[x][j];
            }
        }
        return p[x][0];
    }
};

struct query {
    int x, y, u, v;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    tree<int> t(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--;
        t.add(a, b, c, d);
    }
    t.do_dfs_from(0);
    t.build_lca();
    vector<query> qu;
    vector<map<int, pair<int, int>>> mp(n);
    vector<pair<int, int>> c(n);
    for (int i = 0; i < q; i++) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        u--, v--, x--;
        mp[u][x] = mp[v][x] = mp[t.lca(v, u)][x] = {-1, 0};
        qu.push_back({x, y, u, v});
    }
    function<void(int)> dfs = [&](int v) {
        int pe = t.pe[v];
        if (pe != -1) {
            c[t.edges[pe].col].first += t.edges[pe].cost;
            c[t.edges[pe].col].second++;
        }
        for (auto& p : mp[v]) {
            p.second = c[p.first];
        }
        for (int id : t.g[v]) {
            if (id == pe) continue;
            int to = t.edges[id].from ^ t.edges[id].to ^ v;
            dfs(to);
        }
        if (pe != -1) {
            c[t.edges[pe].col].first -= t.edges[pe].cost;
            c[t.edges[pe].col].second--;
        }
    };
    dfs(0);
    for (int i = 0; i < q; i++) {
        int x = qu[i].x, y = qu[i].y, u = qu[i].u, v = qu[i].v;
        int w = t.lca(u, v);
        int d = t.dist[u] + t.dist[v] - t.dist[w] * 2;
        d -= mp[u][x].first + mp[v][x].first - mp[w][x].first * 2;
        d += (mp[u][x].second + mp[v][x].second - mp[w][x].second * 2) * y;
        cout << d << '\n';
    }
    return 0;
}

Measured memory_bytes: 47216