#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
ll MOD;
//ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int n,q;
bool used[114514];
vpii g[114514];
int d[114514];
int p[20][114514];
void dfs0(int x){
	used[x]=1;
	for(auto pr:g[x]){
        int y=pr.first;
		if(!used[y]){
			d[y]=d[x]+1;
			p[0][y]=x;
			dfs0(y);
		}
	}
}
void init_lca(){
    dfs0(0);
	for(int i=1; i<17; i++){
        for(int x=0; x<n; x++){
            p[i][x]=p[i-1][p[i-1][x]];
        }
    }
}
int lca(int a, int b){
    if(d[a]>d[b]) swap(a, b);
    int a1=a, b1=b;
    int dd=d[b]-d[a], i=0;
    while(dd>0){
        if(dd%2==1){
            b1=p[i][b1];
        }
        dd/=2;
        i++;
    }
    if(a1==b1) return a1;
    for(int i=16; i>=0; i--){
        if(p[i][a1]!=p[i][b1]){
            a1=p[i][a1], b1=p[i][b1];
        }
    }
    return p[0][a1];
}
vi v[114514];
vi vm[114514];
int col[114514]; ll dist[114514];
int colx[114514]; ll y[114514];
ll cnt[114514], dc[114514], ds;
ll ans[114514];
void dfs(int x){
    used[x]=1;
    for(auto i:v[x]){
        ans[i]+=(ds-dc[colx[i]]+cnt[colx[i]]*y[i]);
    }
    for(auto i:vm[x]){
        ans[i]-=2*(ds-dc[colx[i]]+cnt[colx[i]]*y[i]);
    }
    for(auto pr:g[x]){
        int y=pr.first;
        if(used[y]) continue;
        int i=pr.second;
        cnt[col[i]]++;
        dc[col[i]]+=dist[i];
        ds+=dist[i];
        dfs(y);
        cnt[col[i]]--;
        dc[col[i]]-=dist[i];
        ds-=dist[i];
    }
}
int main(){
    cin>>n>>q;
    for(int i=0; i<n-1; i++){
    	int a, b;
        cin>>a>>b>>col[i]>>dist[i];
        a--; b--;
        g[a].pb(mp(b, i));
        g[b].pb(mp(a, i));
    }
    init_lca();
    for(int i=0; i<q; i++){
        int ui, vi;
		cin>>colx[i]>>y[i]>>ui>>vi;ui--; vi--;
        v[ui].pb(i);
        v[vi].pb(i);
        vm[lca(ui, vi)].push_back(i);
    }
    fill(used, used+n, 0);
    dfs(0);
    for(int i=0; i<q; i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 34428