#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

struct edge{
    long to, cost, col;
};
vector<edge> G[100000];


long dist[100001];
long dist_c[100000];
bool used[100000];
typedef pair<long, long> P;

const long INF = 1e+13;
long idx[100000];
map<long, P> mp[100000];
long cnt[100000];

vector<edge> et;

void dfs(int v, int d){
    used[v] = true;
    dist[v] = d;
    for(long i = 0; i < G[v].size(); i++){
        if(!used[G[v][i].to]){
            edge e = G[v][i];
            idx[G[v][i].to] = et.size()+1;
            et.push_back(e);
            dfs(G[v][i].to, d+e.cost);
            edge f = edge{v, -e.cost, e.col};
            et.push_back(f);
        }
    }
}

template <typename T>
struct segtree{
    long n;
    T UNIT;
    vector<T> dat;
    segtree(long n_, T unit){
        UNIT = unit;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n);
        for(long i = 0; i < 2*n; i++) dat[i] = UNIT;
    }

    //これを変更
    T calc(T a, T b){
        T ans;
        if(dist[a] < dist[b]) ans = a;
        else ans = b;
        return ans;
    }
    void insert(long k, T a){
        dat[k+n-1] = a;
    }
    void update_all(){
        for(long i = n-2; i >= 0; i--){
            dat[i] = calc(dat[i*2+1], dat[i*2+2]);
        }
    }
    //k番目の値(0-indexed)をaに変更
    void update(long k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = calc(dat[k*2+1], dat[k*2+2]);
        }
    }

    //[a, b)
    //区間[a, b]へのクエリに対してはquery(a, b+1, 0, 0, segtree.n)と呼ぶこと
    T query(long a, long b, long k, long l, long r){
        if(r <= a || b <= l) return UNIT;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return calc(vl, vr);
        }
    }
};

int main(){
    long N, Q;
    cin >> N >> Q;
    dist[N] = INF;
    segtree<long> sgt(2*N-1, N);
    for(long i = 0; i < N-1; i++){
        long a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        c--;
        G[a].push_back((edge){b, d, c});
        G[b].push_back((edge){a, d, c});
    }
    dfs(0, 0);
    long d = 0;
    idx[0] = 0;
    sgt.insert(0, 0);
    for(long i = 0; i < et.size(); i++){
        d += et[i].cost;
        //cout << et[i].to << ' ' << d << endl;
        sgt.insert(i+1,et[i].to);
    }
    sgt.update_all();
    for(long i = 0; i < N; i++){
        mp[i][0] = P(0, 0);
    }
    //cout << et.size() << endl;
    for(long i = 0; i < et.size(); i++){
        long c = et[i].col;
        dist_c[c] += et[i].cost;
        long cost = et[i].cost;
        if(cost > 0) cnt[c]++;
        else cnt[c]--;
        //cout << cnt[c] << endl;
        //cout << "col " << c << " v "<< et[i].to << " dist " << dist[i+1] << endl;
        mp[c][i+1] = P(cnt[c], dist_c[c]);
    }
    
    for(long i = 0; i < Q; i++){
        long x, y, u, v;
        cin >> x >> y >> u >> v;
        x--;
        y;
        u--;
        v--;
        long iu = idx[u];
        long iv = idx[v];
        if(iu > iv) swap(iu, iv);
        //cout << iu << ' ' << iv << endl;
        long c_ =  sgt.query(iu, iv+1, 0, 0, sgt.n);
        long ic = idx[c_];
        long d_tmp = dist[u]+dist[v]-dist[c_]*2;
        auto l = mp[x].upper_bound(iu);
        auto c = mp[x].upper_bound(ic);
        auto r = mp[x].upper_bound(iv);
        //cout << "col " << x << " dist ";
        //for(auto iter = mp[x].begin(); iter != mp[x].end(); iter++){
            //cout << iter->first << ":" << iter->second.first << ' ';
        //}
        //cout << endl;
        l--;
        c--;
        r--;
        long cnt_x = (l->second.first+r->second.first-2*c->second.first);
        long dist_x = (l->second.second+r->second.second-2*c->second.second);
        long ans = d_tmp-dist_x+cnt_x*y;
        //cout << iu << ' ' << iv << endl;
        //cout << l->second.second << ' ' << r->second.second << endl;
        //cout << dist[u] << ' ' << dist[v] << ' ' << d_tmp << endl;
        //cout << cnt_x << ' ' << dist_x << endl;
        cout << ans << endl;
    }
}

Measured memory_bytes: 56172