#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF INT_MAX

using namespace std;

//-------------------------------------------------
//--Segment tree
//-------------------------------------------------
template<typename T>
class SegmentTree
{
private:
    using F = function<T(T,T)>;
    ::std::vector<T> btree;
    F f, _update;
    T e;
    int n;
public:
    SegmentTree(int _n, F f, T e, F g=[](T a,T b){return b;})
         : f(f),e(e),_update(g)
    {
        init(_n);
    }
    SegmentTree(const ::std::vector<T> &v, F f, T e, F g=[](T a,T b){return b;})
         : f(f),e(e),_update(g)
    {
        int _n = v.size();
        init(_n);
        for(int i=0; i<_n; i++) btree[i+n-1] = v[i];
        build();
    }
    void init(int _n){
        n = 1;
        while(_n>n) n<<=1;
        btree.resize(2*n-1, e);
    }
    void build(){
        for(int i=n-2; i>=0; i--) btree[i] = f(btree[2*i+1], btree[2*i+2]);
    }
    void update(int k, T a){
        k += n-1;
        btree[k] = _update(btree[k], a);
        while(k>0){
            --k>>=1;
            btree[k] = f(btree[2*k+1], btree[2*k+2]);
        }
    }
    T query(int a, int b){
        T L=e, R=e;
        a+=n-1; b+=n-1;
        while(a<b){
            if (!(a & 1)) L=f(L, btree[a++]);
            if (!(b & 1)) R=f(btree[--b], R);
            a>>=1; b>>=1;
        }
        return f(L, R);
    }
    T operator[](int k){return btree[k+n-1];}
};

using edge = tuple<int,int,int>; //to, color, distance
vector<vector<edge> > adj;

vector<pi> euler;
vi fidx;
int idx = 0;
using edge = tuple<int,int,int>;
vector<vector<edge> > table;
vi euler2;
vi iidx;
int idx2 = 0;

void dfs(int v, int p, int d)
{
    euler.emplace_back(d,v);
    fidx[v] = idx++;
    for(auto e:adj[v]){
        int u,color,dist;
        tie(u,color,dist) = e;
        if (u==p) continue;
        table[color].emplace_back(idx2, dist, 1);
        euler2.pb(dist);
        iidx[u] = idx2++;
        dfs(u,v,d+1);
        euler2.pb(-dist);
        table[color].emplace_back(idx2++, -dist, -1);
        euler.emplace_back(d,v); idx++;
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q; cin>>n>>q;
    adj.resize(n);
    rep(i,n-1){
        int a,b,c,d; cin>>a>>b>>c>>d;
        a--; b--; c--;
        adj[a].emplace_back(b,c,d);
        adj[b].emplace_back(a,c,d);
    }
    fidx.resize(n);
    iidx.resize(n, -1);
    table.resize(n-1);
    rep(i,n-1) table[i].emplace_back(-1, 0, 0);
    euler2.pb(0);
    dfs(0,-1,0);
    rep(i,n-1){
        rep(j,table[i].size()-1){
            get<1>(table[i][j+1]) += get<1>(table[i][j]);
            get<2>(table[i][j+1]) += get<2>(table[i][j]);
        }
    }
    rep(i,euler2.size()-1){
        euler2[i+1] += euler2[i];
    }
    // for(auto e:euler2){
        // cout<<e<<" ";
    // }cout<<endl;
    SegmentTree<pi> seg(euler, [](pi x, pi y){return min(x,y);}, mp(INF,INF));
    while(q--){
        int x,y,a,b; cin>>x>>y>>a>>b;
        x--; a--; b--;
        int fmin = min(fidx[a], fidx[b]);
        int fmax = max(fidx[a], fidx[b]);
        int lca = (seg.query(fmin, fmax+1)).se;
        int dist=0;
        dist += euler2[iidx[a]+1]-euler2[iidx[lca]+1];
        dist += euler2[iidx[b]+1]-euler2[iidx[lca]+1];
        auto aitr = upper_bound(all(table[x]), make_tuple(iidx[lca],INF,INF)); aitr--;
        auto litr = upper_bound(all(table[x]), make_tuple(iidx[a],INF,INF)); litr--;
        auto ritr = upper_bound(all(table[x]), make_tuple(iidx[b],INF,INF)); ritr--;
        dist -= get<1>(*ritr) - get<1>(*aitr);
        dist -= get<1>(*litr) - get<1>(*aitr);
        dist += (get<2>(*ritr)-get<2>(*aitr))*y;
        dist += (get<2>(*litr)-get<2>(*aitr))*y;
        cout<<dist<<endl;
    }
    return 0;
}


Measured memory_bytes: 30304