#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<int> color_offset,answer;

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist;
	RootedNode():depth(0),dist(0){}
};

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	vector<vector<int>> color;
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
		color.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class EulerTour{
public:
	vector<int> tour_history;
	vector<pair<int,int>> partial_tree_index;
	void resize(int node_num){
		partial_tree_index.resize(node_num,make_pair(-1,-1));
	}
};

class Query{
public:
	int index;
	int color,dist;
	int is_lca;
};

map<int,pair<int,int>> memo;
vector<vector<Query>> query;

class RootedTree{
	int parent_size;
public:
	void DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		node[child].dist = dist;
		
		for(auto& x:query[child]){
			int res;
			if(!memo.count(x.color)) res = dist;
			else res = dist-memo[x.color].first+x.dist*memo[x.color].second;
			if(x.is_lca) answer[x.index] -= 2*res;
			else answer[x.index] += res;
		}

		for(int i = 0;i < connection[child].size();i++){
			if(connection[child][i].first != parent){
				memo[connection.color[child][i]].first += connection[child][i].second;
				memo[connection.color[child][i]].second++;
				DFS(connection,connection[child][i].first,child,dep+1,dist+connection[child][i].second);
				memo[connection.color[child][i]].first -= connection[child][i].second;
				memo[connection.color[child][i]].second--;
			}
		}
	}
public:
	vector<RootedNode> node;
	EulerTour euler_tour;

	RootedTree(ConnectNodeInfo& connection){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size);
		DFS(connection,0,-1,0,0);
		for(int k=0;k<parent_size-1;k++){
			for(int v=0,ev=connection_size;v<ev;v++){
				if(node[v].parent[k] < 0) node[v].parent[k+1] = -1;
				else node[v].parent[k+1] = node[node[v].parent[k]].parent[k];
			}
		}
	}
	ll FindLCA(ll u,ll v){
		if(node[u].depth > node[v].depth) swap(u,v);
		for(int k=0;k<parent_size;k++){
			if((node[v].depth - node[u].depth) & (1LL<<k)){
				v = node[v].parent[k];
			}
		}
		if(u==v) return u;
		for(int k=parent_size-1;k>=0;k--){
			if(node[u].parent[k] != node[v].parent[k]){
				u = node[u].parent[k];
				v = node[v].parent[k];
			}
		}
		return node[u].parent[0];
	}
};

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

	int N=in(),Q=in();
	ConnectNodeInfo connect(N);
	color_offset.resize(N);
	REP(i,N-1){
		int a=in()-1,b=in()-1,c=in(),d=in();
		connect.AddNonDirectionalConnection(a,b,d);
		connect.color[a].push_back(c);
		connect.color[b].push_back(c);
	}
	query.resize(N);
	answer.resize(Q,0);
	RootedTree tree(connect);
	memo.clear();
	fill(ALL(answer),0);
	REP(i,Q){
		Query new_query{i,in(),in()};
		int u=in()-1,v=in()-1;
		new_query.is_lca = 0;
		query[u].emplace_back(new_query);
		query[v].emplace_back(new_query);
		new_query.is_lca = 1;
		query[tree.FindLCA(u,v)].emplace_back(new_query);
	}
	tree.DFS(connect,0,-1,0,0);
	
	for(auto& x:answer){
		out(x);
	}
	
	return 0;
}


Measured memory_bytes: 54140