#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

template<typename Monoid> struct Segment_Tree{
    //二項演算
    Monoid ope(Monoid a, Monoid b) {return min(a, b);}
    //単位元
    Monoid unit;
    int n;
    vector<Monoid> seg;
    //要素数N(0-indexed)のxを単位元とするセグメント木を構築
    Segment_Tree(int N, Monoid x){
        unit = x;
        n = 1;
        while(n < N) n *= 2;
        seg.assign(2*n, unit);
    }
    //i番目の要素をxに変更
    void change(int i, Monoid x){
        i += n;
        seg[i] = x;
        while(i > 0){
            i /= 2;
            seg[i] = ope(seg[2*i], seg[2*i+1]);
        }
    }
    //query(a, b)で[a, b)における演算の結果を取得
    Monoid query(int a, int b, int i = 1, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return unit;
        elif(a <= l && r <= b) return seg[i];
        else{
            Monoid vl = query(a, b, 2*i, l, (l+r)/2);
            Monoid vr = query(a, b, 2*i+1, (l+r)/2, r);
            return ope(vl, vr);
        }
    }
    //i番目の要素を取得
    Monoid at(int i){
        return seg[n+i]; 
    }
    //初期化する
    void clear(){
        fill(seg.begin(), seg.end(), unit);
    }
};

struct edge{int to, col, len;};

const int MAX_V = 1e5;
vector<edge> es[MAX_V];
vector<int> Vs, depth;
vector<edge> Es;
vector<int> id(MAX_V, inf);
Segment_Tree<pii> seg(2*MAX_V, pii(inf, inf));

void Euler_Tour(int now, int pre, int d){
    Vs.pb(now);
    depth.pb(d);
    edge memo;
    for(auto &e: es[now]){
        if(e.to == pre){
            memo = e;
            continue;
        }
        Es.emplace_back(e);
        Euler_Tour(e.to, now, d+1);
        Vs.pb(now);
        depth.pb(d);
    }
    memo.len *= -1;
    if(pre != -1) Es.emplace_back(memo);
}

int lca(int u, int v){
    pii p = seg.query(min(id[u], id[v]), max(id[u], id[v])+1);
    return Vs[p.second];
}

int main(){
    int N, Q;
    cin >> N >> Q;
    rep(i, N-1){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--;
        es[a].emplace_back((edge){b, c, d});
        es[b].emplace_back((edge){a, c, d});
    }
    Euler_Tour(0, -1, 0);
    vector<int> col_es[N-1];
    vector<int> sum;
    vector<int> col_sum[N-1], col_num[N-1];
    sum.pb(0);
    rep(i, Es.size()){
        edge e = Es[i];
        col_es[e.col].pb(i);
        sum.pb(sum[sum.size()-1] + e.len);
    }
    rep(i, N-1){
        col_sum[i].pb(0), col_num[i].pb(0);
        for(auto &j: col_es[i]){
            edge e = Es[j];
            col_sum[i].pb(col_sum[i][col_sum[i].size()-1] + e.len);
            col_num[i].pb(col_num[i][col_num[i].size()-1] + e.len/abs(e.len));
        }
    }
    rep(i, Vs.size()){
        id[Vs[i]] = min(id[Vs[i]], i);
        seg.change(i, pii(depth[i], i));
    }
    rep(i, Q){
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        x--, u--, v--;
        if(id[u] > id[v]) swap(u, v);
        int k = lca(u, v);
        int ans = sum[id[u]] + sum[id[v]] - 2*sum[id[k]];
        int l = lower_bound(all(col_es[x]), id[u]) - col_es[x].begin();
        int r = lower_bound(all(col_es[x]), id[v]) - col_es[x].begin();
        int n = lower_bound(all(col_es[x]), id[k]) - col_es[x].begin();
        ans += (col_num[x][r] + col_num[x][l] - 2*col_num[x][n])*y;
        ans -= col_sum[x][r] + col_sum[x][l] - 2*col_sum[x][n];
        cout << ans << endl;
    }
}

Measured memory_bytes: 33324