#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;


struct LCA{
    private:
    int n,root,k=0;
    vector<vector<int>> D,G;
    vector<int> depth;
    public:

    void dfs(int s,int par){
        D[s].push_back(par);
        if (par!=-1) depth[s]=depth[par]+1;
        rep(i,G[s].size()){
            int t=G[s][i];
            if (t==par) continue;
            dfs(t,s);
        }
    }
    
    void init(int n_,int r,vector<vector<int>> G_){
        n=n_;
        G=G_;
        root=r;
        depth.resize(n,0);
        D.resize(n,{});
        dfs(root,-1);
        while(true){
            bool flag=false;
            int m=(1<<k);
            rep(i,n){
                if (D[i][k]==-1) D[i].push_back(-1);
                else{
                    if (D[D[i][k]][k]!=-1) flag=true;
                    D[i].push_back(D[D[i][k]][k]);
                }
            }
            if (!flag) break;
            k+=1;
        }
    }

    int lca(int p,int q){
        if (depth[p]<depth[q]) swap(p,q);
        per(i,k+1){
            if (((depth[p]-depth[q]) & (1 << i))!=0) p=D[p][i];
        }
        if (p==q) return p;
        per(i,k+1){
            if (D[p][i]!=D[q][i]) {
                p=D[p][i];
                q=D[q][i];
            }
        }
        return D[p][0];
    }

    
};

int n,q,k=0;
vector<vector<int>> G;
vector<vector<P>> G2;
vector<int> lth,color,S={0};
vector<int> idx;
vector<vector<P>> su,nu;


void dfs(int s,int par,int edge){
    if (par!=-1){
        idx[s]=k+1;
        k+=1;
        su[color[edge]].push_back(P(k,su[color[edge]].back().second+lth[edge]));
        nu[color[edge]].push_back(P(k,nu[color[edge]].back().second+1));
        S.push_back(S.back()+lth[edge]);
    }
    rep(i,G2[s].size()){
        int t=G2[s][i].first,e=G2[s][i].second;
        if (par==t) continue;
        dfs(t,s,e);
    }
    if (par!=-1){
        k+=1;
        su[color[edge]].push_back(P(k,su[color[edge]].back().second-lth[edge]));
        nu[color[edge]].push_back(P(k,nu[color[edge]].back().second-1));
        S.push_back(S.back()-lth[edge]);
    }
}

int dist(int s,int c,int y){
    int res=0;
    res+=S[idx[s]];
    //cout << S[idx[s]] << endl;
    auto itr_nu=lower_bound(nu[c].begin(),nu[c].end(),P(idx[s]+1,0));
    auto itr_su=lower_bound(su[c].begin(),su[c].end(),P(idx[s]+1,0));
    //auto itr_su=lower_bound(su[c].begin(),su[c].end(),idx[s]);
    itr_nu--;itr_su--;
    //cout << s << " " << (*itr_nu).first << endl;
    //cout << y*((*itr_nu).second) << endl;
    res+=y*((*itr_nu).second);
    res-=(*itr_su).second;
    return res;
}

void solve(){
    cin >> n >> q;
    G.resize(n,{});
    G2.resize(n,{});
    nu.resize(n,{});
    su.resize(n,{});
    idx.resize(n,0);
    rep(i,n){
        su[i].push_back(P(-1,0));
        nu[i].push_back(P(-1,0));
    }
    rep(i,n-1){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
        G2[a-1].push_back(P(b-1,i));
        G2[b-1].push_back(P(a-1,i));
        color.push_back(c-1);
        lth.push_back(d);
    }

    LCA l;l.init(n,0,G);
    dfs(0,-1,0);
    rep(i,n-1){
        //cout << "color: " << i << endl;
        nu[i].push_back(P(k,0));
        su[i].push_back(P(k,0));
        rep(j,nu[i].size()){
            //cout << nu[i][j].first << " " << nu[i][j].second << " " << su[i][j].second << endl; 
        }
    }
    rep(i,q){
        int x,y,u,v;
        cin >> x >> y >> u >> v;
        x--;u--;v--;
        int p=l.lca(u,v);
        cout << dist(u,x,y)+dist(v,x,y)-2*dist(p,x,y) << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 59336