#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
struct edge { int id, to, color, cost; };
vector< edge > nex[114514];
vector<pair<int,int> > quer,quer2;
vector< pair<int, int> > colnum[114514],coldis[114514];
int n,q,k;
int par[20][114514];
int depth[114514],id[114514],vs[214514],st[114514],sum[214514];
void lcadfs(int v,int p,int d){
	par[0][v] = p;
	depth[v] = d;
	for(int i=0;i<nex[v].size();i++){
		if( nex[v][i].to != p ) lcadfs( nex[v][i].to, v, d+1 );
	}
}
int lca(int u,int v){
	if(depth[u] > depth[v]) swap(u,v);
	for(int k=0;k<=17;k++){
		if( ( (depth[v] - depth[u] ) >> k ) & 1 ){
			v = par[k][v];
		}
	}
	if( u == v )return u;
	for(int k=17;k>=0;k--){
		if( par[k][u] != par[k][v] ){
			u = par[k][u];
			v = par[k][v];
		}
	}
	return par[0][u];
}
void dfs(int v,int p,int &k){
	id[v] = k;
	vs[k] = v;
	for(int i=0;i<nex[v].size();i++){
		edge &e = nex[v][i];
		if( e.to != p ){
			sum[k] = sum[k-1]+e.cost;
			colnum[ e.color ].pb( mp(k, 1) );
			coldis[ e.color ].pb( mp(k, e.cost) );
			k++;
			//cout<<k<<" "<<e.cost<<endl;
			dfs(e.to, v, k);
			vs[k] = v;
			sum[k] = sum[k-1]-e.cost;
			colnum[ e.color ].pb( mp(k, -1) );
			coldis[ e.color ].pb( mp(k, -e.cost) );
			k++;
			//cout<<k<<" "<<-e.cost<<endl;
		}
	}
}
void init(int n){
	lcadfs(1,0,0);
	for(int k=0;k<=17;k++){
		for(int v=1;v<=n;v++){
			if( par[k][v] <= 0 )par[k+1][v]=0;
			par[k+1][v] = par[k][par[k][v]];
		}
	}
	k = 1;
	for(int i=1;i<=n;i++){
		colnum[i].pb(mp(0,0));
		coldis[i].pb(mp(0,0));
	}
	dfs(1,-1,k);
	for(int i=1;i<=n;i++){
		for(int j=1;j<colnum[i].size();j++){
			colnum[i][j].second += colnum[i][j-1].second;
			coldis[i][j].second += coldis[i][j-1].second;
		}
	}
	for(int i=1;i<=n;i++)id[i]--;
}
int getnum(int c,int p1,int p2,int oy){
	int res = 0;
	if( colnum[c].empty() )return 0;
	//cout<<"ids "<<id[p1]<<" "<<id[p2]<<" "<<id[oy]<<endl;
	//for(int i=0;i<colnum[c].size();i++){ cout<<colnum[c][i].first<<" "<<colnum[c][i].second<<endl;}
	pair<int,int> P;
	vector< pair<int,int> >::iterator it = upper_bound( colnum[c].begin(), colnum[c].end(), mp( id[p1], LINF) );
	it--;
	P = *it;
	res += P.second;
	it = upper_bound( colnum[c].begin(), colnum[c].end(), mp( id[p2], LINF) );
	it--;
	P = *it;
	res += P.second;
	it = upper_bound( colnum[c].begin(), colnum[c].end(), mp( id[oy], LINF) );
	it--;
	P = *it;
	res -= 2*P.second;
	return res;
}
int getchd(int c,int p1,int p2,int oy){
	int res = 0;
	if( coldis[c].empty() )return 0;
	//cout<<"ids "<<id[p1]<<" "<<id[p2]<<" "<<id[oy]<<endl;
	//for(int i=0;i<coldis[c].size();i++){ cout<<coldis[c][i].first<<" "<<coldis[c][i].second<<endl;}
	pair<int,int> P;
	vector< pair<int,int> >::iterator it = upper_bound( coldis[c].begin(), coldis[c].end(), mp( id[p1], LINF) );
	it--;
	P = *it;
	res += P.second;
	it = upper_bound( coldis[c].begin(), coldis[c].end(), mp( id[p2], LINF) );
	it--;
	P = *it;
	res += P.second;
	it = upper_bound( coldis[c].begin(), coldis[c].end(), mp( id[oy], LINF) );
	it--;
	P = *it;
	res -= 2*P.second;
	return res;
}
signed main(){
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int aa,bb,cc,dd;
		cin>>aa>>bb>>cc>>dd;
		nex[aa].pb( (edge){i,bb,cc,dd} );
		nex[bb].pb( (edge){i,aa,cc,dd} );
	}
	init(n);
	for(int i=0;i<q;i++){
		int xx,yy,zz,ww;
		cin>>xx>>yy>>zz>>ww;
		quer.pb(mp(xx,yy));
		quer2.pb(mp(zz,ww));
	}
	for(int i=0;i<q;i++){
		int ccol = quer[i].first;
		int cdis = quer[i].second;
		int pos1 = quer2[i].first;
		int pos2 = quer2[i].second;
		int pa = lca(pos1,pos2);
		int di = sum[ id[pos1] ] + sum[ id[pos2] ] - 2 * sum[ id[pa] ];
		int num = getnum( ccol, pos1, pos2, pa );
		int chd = getchd( ccol, pos1, pos2, pa );
		//cout<<di<<" "<<num<<" "<<chd<<endl;
		cout<< di + num * cdis - chd << endl;
	}
	return 0;
}

Measured memory_bytes: 68064