#include<bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

struct heavy_light_decomposition {
    int n;
    std::vector<std::vector<int>> graph;
    std::vector<int> par, size, in, out, head;
    int idx;
    heavy_light_decomposition(int n) : n(n), graph(n), par(n), size(n), in(n), out(n), head(n) {}
    void add_edge(int u, int v) {
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    void dfs_size(int v, int p) {
        size[v] = 1;
        par[v] = p;
        for (int i = 0; i < graph[v].size(); i++) {
            int &u = graph[v][i];
            if (u == p) { continue; }
            dfs_size(u, v);
            size[v] += size[u];
            if (size[u] > size[graph[v][0]]) { std::swap(u, graph[v][0]); }
        }
    }
    void dfs_hld(int v) {
        in[v] = idx++;
        for (int i = 0; i < graph[v].size(); i++) {
            int u = graph[v][i];
            if (u == par[v]) { continue; }
            head[u] = (i == 0 ? head[v] : u);
            dfs_hld(u);
        }
        out[v] = idx;
    }
    std::vector<int> build(int root) {
        idx = 0;
        dfs_size(root, -1);
        head[root] = root;
        dfs_hld(root);
        std::vector<int> ret(n);
        for (int i = 0; i < n; i++) { ret[in[i]] = i; }
        return ret;
    }
    int get_lca(int u, int v) {
        while (true) {
            if (in[u] > in[v]) { std::swap(u, v); }
            if (head[u] == head[v]) { return u; }
            v = par[head[v]];
        }
    }
    void path_query(int u, int v, const std::function<void(int, int)> &f) {
        while (true) {
            if (in[u] > in[v]) { std::swap(u, v); }
            f(std::max(in[head[v]], in[u]), in[v] + 1);
            if (head[u] == head[v]) { return; }
            v = par[head[v]];
        }
    }
    void subtree_query(int v, const std::function<void(int, int)> &f) {
        f(in[v], out[v]);
    }
};

int N, Q;
int a[110000], b[110000], c[110000], d[110000];
int x[110000], y[110000], u[110000], v[110000];
struct edge {
    int to, color, len;
};
vector<edge> G[110000];
vint required[110000];
int cur_dist_all = 0;
int dist_all[110000];
map<int, int> dist[110000], num[110000];
int cur_dist[110000], cur_num[110000];
void dfs(int idx, int p) {
    dist_all[idx] = cur_dist_all;
    rep(i, required[idx].size()) {
        int color = required[idx][i];
        dist[idx][color] = cur_dist[color];
        num[idx][color] = cur_num[color];
    }
    rep(i, G[idx].size()) {
        int to = G[idx][i].to, color = G[idx][i].color, len = G[idx][i].len;
        if (to == p) { continue; }
        cur_dist_all += len;
        cur_dist[color] += len;
        cur_num[color]++;
        dfs(to, idx);
        cur_dist_all -= len;
        cur_dist[color] -= len;
        cur_num[color]--;
    }
}
signed main() {
    cin >> N >> Q;
    heavy_light_decomposition hld(N);
    rep(i, N - 1) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
        hld.add_edge(a[i], b[i]);
        G[a[i]].push_back({b[i], c[i], d[i]});
        G[b[i]].push_back({a[i], c[i], d[i]});
    }
    hld.build(0);
    rep(i, Q) {
        cin >> x[i] >> y[i] >> u[i] >> v[i];
        u[i]--, v[i]--;
        required[u[i]].push_back(x[i]);
        required[v[i]].push_back(x[i]);
        required[hld.get_lca(u[i], v[i])].push_back(x[i]);
    }
    dfs(0, -1);
    rep(i, Q) {
        int lca = hld.get_lca(u[i], v[i]), color = x[i], len = y[i];
        int ans = dist_all[u[i]] + dist_all[v[i]] - 2 * dist_all[lca];
        ans -= dist[u[i]][color] + dist[v[i]][color] - 2 * dist[lca][color];
        ans += (num[u[i]][color] + num[v[i]][color] - 2 * num[lca][color]) * len;
        cout << ans << endl;
    }

}

Measured memory_bytes: 79644