// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

template <size_t Size = 30>
class Lca {
    const ll nopt;
    ll N;
    ll root;
    V<ll> depth;
    VV<ll> edge;
    VV<ll> parents;

    void dfs(ll now, ll pre, ll d) {
        parents[now][0] = pre;
        depth[now] = d;
        for(ll next : edge[now]) {
            if(next != pre) {
                dfs(next, now, d + 1);
            }
        }
    }

public:
    Lca(ll N, ll root, const vector<vector<ll>> &e)
        : nopt(-1),
          N(N),
          root(root),
          edge(e),
          parents(N, V<ll>(Size))
    {
        depth.resize((size_t)N);
        dfs(root, nopt, 0);

        for(ll i = 1; i < Size; i++) {
            for(ll node = 0; node < N; node++) {
                if(parents[node][i - 1] == nopt) {
                    parents[node][i] = nopt;
                } else {
                    parents[node][i] = parents[parents[node][i - 1]][i - 1];
                }
            }
        }
    }

    Lca(ll n, const vector<vector<ll>> &e) : Lca(n, 0, e) 
    {
    }

    ll get_depth(ll node) { return depth[node]; }

    ll get_parents(ll node, ll relative_depth) {
        ll ret = node;
        for(ll i = 0; (1 << i) <= relative_depth && ret != -1; i++) {
            if(relative_depth & (1 << i)) {
                ret = parents[ret][i];
            }
        }
        return ret;
    }

    ll get_lca(ll n1, ll n2) {
        ll d = min(depth[n1], depth[n2]);
        ll ok = 0, ng = d + 1;
        ll ret = 0;
        while(abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            ll p1 = get_parents(n1, depth[n1] - mid);
            ll p2 = get_parents(n2, depth[n2] - mid);
            if(p1 == p2) {
                ok = mid;
                ret = p1;
            } else {
                ng = mid;
            }
        }
        return ret;
    }
};

// to, color, dist;
using Edge = tuple<ll, ll, ll>;

// x, y, u, v, parent, idx;
using Query = tuple<ll, ll, ll, ll, ll, ll>;

VV<Edge> edges, redges;
VV<ll> edges_lca;
VV<ll> colors;
// cnt, dist
VV<PLL> colors_info;
V<ll> dists;

void dfs(ll now, ll pre, V<PLL> &count_color, ll dist_sum) {
    dists[now] = dist_sum;
    for(ll col : colors[now]) colors_info[now].push_back(count_color[col]);
    for(auto &&e : edges[now]) {
        ll to, col, dis;
        tie(to, col, dis) = e;
        if(pre == to) continue;
        auto &ele = count_color[col];
        ele.first++;
        ele.second += dis;
        dfs(to, now, count_color, dist_sum + dis);
        ele.second -= dis;
        ele.first--;
    }
}

const ll inf = 5e15;

PLL col_edge_info(ll node, ll col) {
    auto ite = lower_bound(ALL(colors[node]), col);
    if(*ite != col) return PLL(0, 0);
    ll idx = ite - colors[node].begin();
    return colors_info[node][idx];
}

int main() {
    ll N, Q;
    cin >> N >> Q;
    edges.resize(N);
    redges.resize(N);
    edges_lca.resize(N);
    colors.resize(N);
    colors_info.resize(N);
    dists.resize(N);
    for(ll i = 1; i < N; i++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        edges[a].emplace_back(b, c, d);
        edges[b].emplace_back(a, c, d);
        edges_lca[a].push_back(b);
        edges_lca[b].push_back(a);
    }

    Lca<> lca(N, 0, edges_lca);
    V<Query> query(Q);
    for(ll i = 0; i < Q; i++) {
        ll x, y, u, v;
        cin >> x >> y >> u >> v;
        u--; v--;
        ll par = lca.get_lca(u, v);
        colors[u].push_back(x);
        colors[v].push_back(x);
        colors[par].push_back(x);
        query[i] = make_tuple(x, y, u, v, par, i);
    }

    for(auto &ele : colors) {
        sort(ALL(ele));
        auto ite = unique(ALL(ele));
        ele.erase(ite, ele.end());
    }

    // cnt, dist
    V<PLL> count_color(N);
    dfs(0, -1, count_color, 0);
    for(auto &ele : colors) ele.push_back(inf);

    for(auto &&que : query) {
        ll x, y, u, v, p, i;
        tie(x, y, u, v, p, i) = que;
        PLL uinfo = col_edge_info(u, x);
        PLL vinfo = col_edge_info(v, x);
        PLL pinfo = col_edge_info(p, x);
        if(p == u || p == v) {
            if(dists[u] > dists[v]) {
                swap(u, v);
                swap(uinfo, vinfo);
            }
            ll pre_dist = dists[v] - dists[u];
            ll pre_col_dist = vinfo.second - uinfo.second;
            ll col_cnt_sum = vinfo.first - uinfo.first;
            cout << pre_dist - pre_col_dist + col_cnt_sum * y << endl;
        } else {
            ll pre_dist = dists[v] + dists[u] - 2 * dists[p];
            ll pre_col_dist = uinfo.second + vinfo.second - 2 * pinfo.second;
            ll col_cnt_sum = uinfo.first + vinfo.first - 2 * pinfo.first;
            cout << pre_dist - pre_col_dist + col_cnt_sum * y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 77688