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<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int,int> >T;
vector<pair<int,pair<int,int> > >G[1<<17];
int N,Q;
int L[1<<17],R[1<<17];
int parent[20][1<<17];
int depth[1<<17];
void tourdfs(int u,int p,int d)
{
	parent[0][u]=p;
	depth[u]=d;
	L[u]=T.size();
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i].first;
		if(v==p)continue;
		T.push_back(G[u][i].second);
		tourdfs(v,u,d+1);
		T.push_back(make_pair(-G[u][i].second.first,G[u][i].second.second));
	}
	R[u]=T.size();
}
long cumsum[1<<20];
const int W=500;
int cnt[1000][1<<17];
long sum[1000][1<<17];
pair<int,long>get(int l,int r,int c)
{
	pair<int,long>ret=make_pair(0,0);
	while(l<T.size()&&l%W!=0&&l<r)
	{
		int nc=T[l].first,nd=T[l].second;
		if(nc>0&&nc==c)
		{
			ret.first++;
			ret.second+=nd;
		}
		else if(-nc==c)
		{
			ret.first--;
			ret.second-=nd;
		}
		l++;
	}
	while(l+W<=r&&l+W<=T.size())
	{
		int nc=cnt[l/W][c];
		long nd=sum[l/W][c];
		ret.first+=nc;
		ret.second+=nd;
		l+=W;
	}
	while(l<r)
	{
		int nc=T[l].first,nd=T[l].second;
		if(nc>0&&nc==c)
		{
			ret.first++;
			ret.second+=nd;
		}
		else if(-nc==c)
		{
			ret.first--;
			ret.second-=nd;
		}
		l++;
	}
	return ret;
}
long calc(int u,int v,int c,int y)
{
	bool flag=false;
	if(L[u]>R[v])
	{
		swap(u,v);
		flag=true;
	}
	long ret=cumsum[R[v]]-cumsum[L[u]];
	pair<int,long>p=get(L[u],R[v],c);
	ret-=p.second;
	ret+=p.first*y;
	return flag?-ret:ret;
}
int lca(int u,int v)
{
	if(depth[u]>depth[v])swap(u,v);
	for(int k=0;k<20;k++)
	{
		if(depth[v]-depth[u]>>k&1)v=parent[k][v];
	}
	if(u==v)return u;
	for(int k=19;k>=0;k--)
	{
		if(parent[k][u]!=parent[k][v])
		{
			u=parent[k][u];
			v=parent[k][v];
		}
	}
	return parent[0][u];
}
int main()
{
	cin>>N>>Q;
	for(int i=1;i<N;i++)
	{
		int a,b,c,d;cin>>a>>b>>c>>d;
		a--,b--;
		G[a].push_back(make_pair(b,make_pair(c,d)));
		G[b].push_back(make_pair(a,make_pair(c,d)));
	}
	tourdfs(0,-1,0);
	for(int i=0;i<T.size();i++)
	{
		cumsum[i+1]=cumsum[i]+(T[i].first<0?-1:1)*T[i].second;
	}
	for(int k=1;k<20;k++)
	{
		for(int i=0;i<N;i++)
		{
			if(parent[k-1][i]>=0)parent[k][i]=parent[k-1][parent[k-1][i]];
			else parent[k][i]=-1;
		}
	}
	for(int i=0;i+W<=T.size();i+=W)
	{
		for(int j=0;j<W;j++)
		{
			int nc=T[i+j].first,nd=T[i+j].second;
			if(nc>0)
			{
				cnt[i/W][nc]++;
				sum[i/W][nc]+=nd;
			}
			else
			{
				cnt[i/W][-nc]--;
				sum[i/W][-nc]-=nd;
			}
		}
	}
	for(;Q--;)
	{
		int x,y,u,v;
		cin>>x>>y>>u>>v;
		u--,v--;
		int pa=lca(u,v);
		cout<<calc(pa,u,x,y)+calc(pa,v,x,y)<<endl;
	}
}