#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

vector<vector<int>> g;
vector<int> h, a, tin;

void dfs(int v, int p = -1) {
    tin[v] = a.size();
    a.push_back(v);
    for (int u : g[v]) {
        if (u != p) {
            h[u] = h[v] + 1;
            dfs(u, v);
        }
    }
    a.push_back(v);
}

struct Query {
    int l, r, x, y, id;
    Query(int a, int b, int c, int d, int i) {
        l = a;
        r = b;
        x = c;
        y = d;
        id = i;
    }

    bool operator<(const Query& a) {
        return r < a.r;
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    g.resize(n);

    vector<pair<pair<int, int>, pair<int, int>>> edges(n - 1);
    for (int i = 0; i < n - 1; i++) {
        int v, u, c, d;
        cin >> v >> u >> c >> d;
        v--; u--;
        edges[i] = { {v, u}, {c, d} };
        g[v].push_back(u);
        g[u].push_back(v);
    }


    vector<int> c(n), d(n);
    h.resize(n);
    tin.resize(n);
    dfs(0);
    for (auto& p : edges) {
        pair<int, int> pp = p.first;
        if (h[pp.first] < h[pp.second]) swap(pp.first, pp.second);
        c[pp.first] = p.second.first;
        d[pp.first] = p.second.second;
    }

    int k = 337;
    vector<vector<Query>> b(a.size() / k + 1);

    for (int i = 0; i < q; i++) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        u--; v--;
        int l = tin[u];
        int r = tin[v];
        if (l > r) swap(l, r);
        l++;
        Query qq(l, r, x, y, i);
        b[l / k].push_back(qq);
    }

    for (int i = 0; i < b.size(); i++) sort(all(b[i]));

    //for (int i : a) cout << i + 1 << " ";
    //cout << '\n';
    vector<bool> ver(n);
    vector<int> cnt(n), sum(n), ans(q);

    for (int i = 0; i < b.size(); i++) {
        if (b[i].empty()) continue;
        int l = b[i][0].l;
        int r = b[i][0].r;
        int res = 0;
        for (int j = l; j <= r; j++) {
            int v = a[j];
            ver[v] = !ver[v];
            if (ver[v]) {
                cnt[c[v]]++;
                sum[c[v]] += d[v];
                res += d[v];
            }
            else {
                cnt[c[v]]--;
                sum[c[v]] -= d[v];
                res -= d[v];
            }
        }

        for (auto& qu : b[i]) {
            int left = qu.l;
            int right = qu.r;
            while (r < right) {
                r++;
                int v = a[r];
                ver[v] = !ver[v];
                if (ver[v]) {
                    cnt[c[v]]++;
                    sum[c[v]] += d[v];
                    res += d[v];
                }
                else {
                    cnt[c[v]]--;
                    sum[c[v]] -= d[v];
                    res -= d[v];
                }
            }
            while (l < left) {
                int v = a[l];
                ver[v] = !ver[v];
                if (ver[v]) {
                    cnt[c[v]]++;
                    sum[c[v]] += d[v];
                    res += d[v];
                }
                else {
                    cnt[c[v]]--;
                    sum[c[v]] -= d[v];
                    res -= d[v];
                }
                l++;
            }
            while (l > left) {
                l--;
                int v = a[l];
                ver[v] = !ver[v];
                if (ver[v]) {
                    cnt[c[v]]++;
                    sum[c[v]] += d[v];
                    res += d[v];
                }
                else {
                    cnt[c[v]]--;
                    sum[c[v]] -= d[v];
                    res -= d[v];
                }
            }

            ans[qu.id] = res - sum[qu.x] + cnt[qu.x] * qu.y;
        }

        for (int j = l; j <= r; j++) {
            int v = a[j];
            cnt[c[v]] = 0;
            sum[c[v]] = 0;
            ver[v] = false;
        }
    }
    for (int i : ans) cout << i << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 25712