#include <bits/stdc++.h>

#define ll long long
#define el cout << '\n'

using namespace std;

const int maxn = 1e5;
const int maxlog = 18;

struct Query
{
    int id, x, y, mobius;
};
struct Edge
{
    int x, c, d;
};

int n, q, beg[maxn + 10], fin[maxn + 10], par[maxn + 10][maxlog + 2], timer = 0;
ll cnt[maxn + 10], sum[maxn + 10], ans[maxn + 10], dist[maxn + 10];
vector<Edge> adj[maxn + 10];
vector<Query> query[maxn + 10];

void precompute(int top, int p = -1)
{
    beg[top] = ++timer;
    for (Edge e : adj[top])
    {
        int next_top = e.x;
        int w = e.d;
        if (next_top == p) continue;
        dist[next_top] = dist[top] + w;
        par[next_top][0] = top;
        precompute(next_top, top);
    }
    fin[top] = timer;
}
bool is_inside(int x, int y)
{
    if (!x) return 1;
    return beg[x] <= beg[y] && fin[y] <= fin[x];
}
int getLCA(int x, int y)
{
    if (is_inside(x, y)) return x;
    if (is_inside(y, x)) return y;
    for (int i = maxlog; i >= 0; i--)
        if (!is_inside(par[x][i], y))
            x = par[x][i];
    return par[x][0];
}
void dfs(int top, int par = -1)
{
    for (Query ask : query[top])
    {
        int id = ask.id;
        int x = ask.x;
        int y = ask.y;
        int mobious = ask.mobius;
        ans[id] += (cnt[x] * y - sum[x]) * mobious;
    }
    for (Edge e : adj[top])
    {
        int next_top = e.x;
        int c = e.c;
        int w = e.d;
        if (next_top == par) continue;
        cnt[c]++;
        sum[c] += w;
        dfs(next_top, top);
        cnt[c]--;
        sum[c] -= w;
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("COLORFUL_TREE.INP", "r"))
    {
        freopen("COLORFUL_TREE.INP", "r", stdin);
        freopen("COLORFUL_TREE.OUT", "w", stdout);
    }

    cin >> n >> q;
    for (int i = 1; i < n; i++)
    {
        int x, y, c, d;
        cin >> x >> y >> c >> d;
        adj[x].push_back({y, c, d});
        adj[y].push_back({x, c, d});
    }
    precompute(1);
    for (int j = 1; j <= maxlog; j++)
        for (int i = 1; i <= n; i++)
            par[i][j] = par[par[i][j - 1]][j - 1];
    for (int i = 1; i <= q; i++)
    {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        int lca = getLCA(u, v);
        ans[i] = dist[u] + dist[v] - 2 * dist[lca];
        query[u].push_back({i, x, y, 1});
        query[v].push_back({i, x, y, 1});
        query[lca].push_back({i, x, y, -2});
    }
    dfs(1);
    for (int i = 1; i <= q; i++)
        cout << ans[i], el;
}