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

int N, Q;
vector<vector<pair<int, int>>> edge;
vector<vector<ll>> tour_cnt, tour_num, tour_sum;
vector<ll> sum;
vector<ll> num;
vector<ll> arrive;
vector<ll> depth;
vector<vector<int>> parent;
vector<ll> dist;
vector<ll> A, B, C, D;
ll d = 0;
int cnt = 0;
int dp = 0;

void dfs(int now, int pre) {
    depth[now] = dp;
    arrive[now] = cnt;
    dist[now] = d;
    
    for (auto p : edge[now]) {
        int nxt = p.first;
        int i = p.second;
        if (pre == nxt) continue;
        parent[nxt][0] = now;
        d += D[i];
        sum[C[i]] += D[i];
        num[C[i]]++;
        cnt++;
        tour_cnt[C[i]].push_back(cnt);
        tour_sum[C[i]].push_back(sum[C[i]]);
        tour_num[C[i]].push_back(num[C[i]]);
        
        dp++;
        dfs(nxt, now);
        dp--;
        
        d -= D[i];
        sum[C[i]] -= D[i];
        num[C[i]]--;
        
        cnt++;
        tour_cnt[C[i]].push_back(cnt);
        tour_sum[C[i]].push_back(sum[C[i]]);
        tour_num[C[i]].push_back(num[C[i]]);
    }
    return;
}

int main() {
    cin >> N >> Q;
    A.resize(N-1);
    B.resize(N-1);
    C.resize(N-1);
    D.resize(N-1);
    edge.resize(N+1);
    parent = vector<vector<int>>(N+1, vector<int>(20, 0));
    dist.resize(N+1, 0);
    tour_cnt.resize(N);
    tour_num.resize(N);
    tour_sum.resize(N);
    sum.resize(N, 0);
    num.resize(N, 0);
    arrive.resize(N+1, 0);
    depth.resize(N+1, 0);
    for (int i = 0; i < N-1; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        edge[A[i]].push_back({B[i], i});
        edge[B[i]].push_back({A[i], i});
    }
    
    for (int i = 1; i < N; i++) {
        tour_cnt[i].push_back(0);
        tour_num[i].push_back(0);
        tour_sum[i].push_back(0);
    }
    
    dfs(1, 0);
    
    for (int i = 1; i < N; i++) {
        tour_cnt[i].push_back(2e9);
        tour_num[i].push_back(2e9);
        tour_sum[i].push_back(2e9);
    }
    
    
    for (int i = 1; i <= 19; i++) {
        for (int j = 1; j <= N; j++) {
            parent[j][i] = parent[parent[j][i-1]][i-1];
        }
    }
    
    
    for (int z = 0; z < Q; z++) {
        ll x, y, u, v;
        cin >> x >> y >> u >> v;
        if (depth[u] > depth[v]) swap(u, v);
        int b = depth[v]-depth[u];
        int ua = u, va = v, a;
        for (int i = 0; i <= 19; i++) {
            if ((b>>i)&1) va = parent[va][i];
        }
        a = va;
        
        while (ua != va) {
            if (parent[ua][0] == parent[va][0]) {
                a = parent[ua][0];
                break;
            }
            int t = 0;
            while (parent[ua][t+1] != parent[va][t+1]) t++;
            ua = parent[ua][t];
            va = parent[va][t];
            a = va;
        }
        
      
        ll ans = dist[u]+dist[v]-dist[a]*2;
        int g;
        auto it = lower_bound(tour_cnt[x].begin(), tour_cnt[x].end(), arrive[u]);
        
        
        if (*it == arrive[u]) {
            g = distance(tour_cnt[x].begin(), it);
        }else {
            g = distance(tour_cnt[x].begin(), --it);
        }
        ans -= tour_sum[x][g];
        ans += y * tour_num[x][g];
        
        
        it = lower_bound(tour_cnt[x].begin(), tour_cnt[x].end(), arrive[v]);
        if (*it == arrive[v]) {
            g = distance(tour_cnt[x].begin(), it);
        }else {
            g = distance(tour_cnt[x].begin(), --it);
        }
        ans -= tour_sum[x][g];
        ans += y * tour_num[x][g];
        
        
        it = lower_bound(tour_cnt[x].begin(), tour_cnt[x].end(), arrive[a]);
        if (*it == arrive[a]) {
            g = distance(tour_cnt[x].begin(), it);
        }else {
            g = distance(tour_cnt[x].begin(), --it);
        }
        ans += tour_sum[x][g]*2;
        ans -= y * tour_num[x][g]*2;
        
        cout << ans << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 53600