#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
struct node{int x,y,z;};
int f[100005][20],n,h[100005],ans[100005],c[100005],co[100005],de[100005]; 
V<node> v[100005],q[100005];
void get(int p){
	h[p]=h[f[p][0]]+1;
	for(auto u:v[p]){
		if(u.x!=f[p][0]){
			f[u.x][0]=p;de[u.x]=de[p]+u.z;
			get(u.x);
		}
	}
}
int lca(int x,int y){
	if(h[x]>h[y])swap(x,y);
	int t=h[y]-h[x];
	FOR(i,0,17){
		if(t&(1<<i))y=f[y][i];
	}
	if(x==y)RE x;
	for(int i=17;i>=0;i--){
		if(f[x][i]!=f[y][i]){
			x=f[x][i];y=f[y][i];
		}
	}
	RE f[x][0];
}
void dfs(int p){
	for(auto u:q[p]){
		if(u.x>0){
			ans[u.x]+=de[p]+c[u.y]*u.z-co[u.y];
		}else{
			ans[-u.x]-=2*(de[p]+c[u.y]*u.z-co[u.y]);
		}
	}
	for(auto u:v[p]){
		if(u.x==f[p][0])continue;
		c[u.y]++;co[u.y]+=u.z;
		dfs(u.x);
		c[u.y]--;co[u.y]-=u.z;
	} 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y,c,d,m;
	cin>>n>>m;
	FOR(i,2,n){
		cin>>x>>y>>c>>d;
		v[x].PB({y,c,d});
		v[y].PB({x,c,d});
	}
	get(1);
	FOR(i,1,17)FOR(j,1,n)f[j][i]=f[f[j][i-1]][i-1];
	FOR(i,1,m){
		cin>>c>>d>>x>>y;
		q[x].PB({i,c,d});
		q[y].PB({i,c,d});
		q[lca(x,y)].PB({-i,c,d});
	}
	dfs(1);
	FOR(i,1,m)cout<<ans[i]<<'\n';
	RE 0;
}


### Prompt

Your task is to create a Cpp solution to the following 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

### Response

```cpp
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
struct node{int x,y,z;};
int f[100005][20],n,h[100005],ans[100005],c[100005],co[100005],de[100005]; 
V<node> v[100005],q[100005];
void get(int p){
	h[p]=h[f[p][0]]+1;
	for(auto u:v[p]){
		if(u.x!=f[p][0]){
			f[u.x][0]=p;de[u.x]=de[p]+u.z;
			get(u.x);
		}
	}
}
int lca(int x,int y){
	if(h[x]>h[y])swap(x,y);
	int t=h[y]-h[x];
	FOR(i,0,17){
		if(t&(1<<i))y=f[y][i];
	}
	if(x==y)RE x;
	for(int i=17;i>=0;i--){
		if(f[x][i]!=f[y][i]){
			x=f[x][i];y=f[y][i];
		}
	}
	RE f[x][0];
}
void dfs(int p){
	for(auto u:q[p]){
		if(u.x>0){
			ans[u.x]+=de[p]+c[u.y]*u.z-co[u.y];
		}else{
			ans[-u.x]-=2*(de[p]+c[u.y]*u.z-co[u.y]);
		}
	}
	for(auto u:v[p]){
		if(u.x==f[p][0])continue;
		c[u.y]++;co[u.y]+=u.z;
		dfs(u.x);
		c[u.y]--;co[u.y]-=u.z;
	} 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y,c,d,m;
	cin>>n>>m;
	FOR(i,2,n){
		cin>>x>>y>>c>>d;
		v[x].PB({y,c,d});
		v[y].PB({x,c,d});
	}
	get(1);
	FOR(i,1,17)FOR(j,1,n)f[j][i]=f[f[j][i-1]][i-1];
	FOR(i,1,m){
		cin>>c>>d>>x>>y;
		q[x].PB({i,c,d});
		q[y].PB({i,c,d});
		q[lca(x,y)].PB({-i,c,d});
	}
	dfs(1);
	FOR(i,1,m)cout<<ans[i]<<'\n';
	RE 0;
}


```