Problem: There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.

Answer the following Q queries:

* Query j (1 \leq j \leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)

Constraints

* 2 \leq N \leq 10^5
* 1 \leq Q \leq 10^5
* 1 \leq a_i, b_i \leq N
* 1 \leq c_i \leq N-1
* 1 \leq d_i \leq 10^4
* 1 \leq x_j \leq N-1
* 1 \leq y_j \leq 10^4
* 1 \leq u_j < v_j \leq N
* The given graph is a tree.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N Q
a_1 b_1 c_1 d_1
:
a_{N-1} b_{N-1} c_{N-1} d_{N-1}
x_1 y_1 u_1 v_1
:
x_Q y_Q u_Q v_Q


Output

Print Q lines. The j-th line (1 \leq j \leq Q) should contain the answer to Query j.

Example

Input

5 3
1 2 1 10
1 3 2 20
2 4 4 30
5 2 1 40
1 100 1 4
1 100 1 5
3 1000 3 4


Output

130
200
60

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int nax=1e5+5;
pair<int,int> arr[nax];
vector<vector<pair<int,pair<int,ll>>>> v(nax);
int vis[nax]={0};
vector<map<int,map<int,int>>> pre(nax);
int level[nax];
int parent[nax];
int dp[nax][20];
struct s{
	int a,b,c,d;
};
int find(int x, int d){
	for(int i=19;i>=0;i--){
		if(d < (1<<i)) continue;
		x=dp[x][i];
		d-=(1<<i);
	}
	return x;
}
void dfs(int ci, int l){
	vis[ci]=1;
	level[ci]=l;
	if(l==0) parent[ci]=ci;
	for(auto x : v[ci]){
		if(vis[x.first]==1) continue;
		parent[x.first]=ci;
		dfs(x.first,l+1);
	}
}
int lca(int a, int b){
	int p=a; int q=b;
	if(level[a] > level[b]){
		p=b; q=a;
	}
	q=find(q,abs(level[a]-level[b]));
	if(p==q) return p;
	for(int i=19;i>=0;i--){
		if(dp[p][i]==dp[q][i]) continue;
		p=dp[p][i];
		q=dp[q][i];
	}
	return dp[p][0];
}
void dfs1(int ci, int sum, int col, int val){
	vis[ci]=1;
	for(auto x : pre[ci]){
		for(auto y: x.second){
			pre[ci][x.first][y.first]=sum-(ll)arr[x.first].second+arr[x.first].first*y.first;
		}
	}
	for(auto x : v[ci]){
		if(vis[x.first]==1) continue;
		arr[x.second.first].first++;
		arr[x.second.first].second+=x.second.second;
		dfs1(x.first,sum+x.second.second,x.second.first,x.second.second);
	}
	if(col != -1){
		arr[col].first--;
		arr[col].second-=val;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--; b--; c--;
		v[a].push_back({b,{c,d}});
		v[b].push_back({a,{c,d}});
		arr[i]={0,0};
	}

	dfs(0,0);
	for(int i=0;i<n;i++){
		vis[i]=0;
		dp[i][0]=parent[i];
	}
	for(int j=1;j<20;j++){
		for(int i=0;i<n;i++) dp[i][j]=dp[dp[i][j-1]][j-1];
	}
	vector
 query;
	for(int i=0;i<q;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--; c--; d--;
		query.push_back({a,b,c,d});
		pre[c][a][b]=0;
		pre[d][a][b]=0;
		pre[lca(c,d)][a][b]=0;
	}
	dfs1(0,0,-1,-1);
	for(auto x : query){
		cout<<pre[x.c][x.a][x.b]+pre[x.d][x.a][x.b]-2*pre[lca(x.c,x.d)][x.a][x.b]<<"\n";
	}
}