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>
#define FOR(i,l,r) for(int i=(l),i##R=(r);i<=i##R;i++)
#define DOR(i,r,l) for(int i=(r),i##L=(l);i>=i##L;i--)
#define loop(i,n) for(int i=0,i##R=(n);i<i##R;i++)
#define sf scanf
#define pf printf
#define mms(a,x) memset(a,x,sizeof a)
#define pb push_back
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chkmax(A &x,const B y){if(x<y)x=y;}
template<typename A,typename B>inline void chkmin(A &x,const B y){if(x>y)x=y;}
const int N=1e5+5,P=1e9+7;
int n,q;
struct Graph{
	int tot,to[N<<1],nxt[N<<1],len[N<<1],col[N<<1],head[N];
	void add(int x,int y,int c,int d){tot++;to[tot]=y;nxt[tot]=head[x];col[tot]=c;len[tot]=d;head[x]=tot;}
	void clear(){mms(head,-1);tot=0;}
	#define EOR(G,i,x) for(int i=G.head[x];i!=-1;i=G.nxt[i])
}G;
int fa[N],dep[N],son[N],sz[N],top[N];
int bel[N];
ll dis[N];
struct node{
	int id;
	int x,y,c,d;
}Q[N];
void dfs(int x,int f){
	fa[x]=f;
	dep[x]=dep[f]+1;
	son[x]=0,sz[x]=1;
	EOR(G,i,x){
		int v=G.to[i];
		if(v==f)continue;
		dis[v]=dis[x]+G.len[i];
		bel[v]=G.col[i];
		dfs(v,x);
		sz[x]+=sz[v];
		if(sz[son[x]]<sz[v])son[x]=v;
	}
}
void top_dfs(int x,int f,int tp){
	top[x]=tp;
	if(son[x])top_dfs(son[x],x,tp);
	EOR(G,i,x){
		int v=G.to[i];
		if(v==f||v==son[x])continue;
		top_dfs(v,x,v);
	}
}
int LCA(int a,int b){
	while(top[a]!=top[b]){
		if(dep[top[a]]>dep[top[b]])a=fa[top[a]];
		else b=fa[top[b]];
	}
	return dep[a]>dep[b]?b:a;
}
int cnt[N],cnt1[N];
ll sum[N],sum1[N],ans[N];
vector<int>mark[N];
void redfs(int x,int f){
	loop(i,mark[x].size()){
		int id=mark[x][i];
		if(id>0){
			cnt[id]=cnt1[Q[id].c];
			sum[id]=sum1[Q[id].c];
		}
		else if(id<0){
			id=-id;
//			pf("cnt:%d d:%d sum:%lld\n",cnt1[Q[id].c]-cnt[id],Q[id].d,sum1[Q[id].c]-sum[id]);
			ans[id]+=1ll*(cnt1[Q[id].c]-cnt[id])*Q[id].d-(sum1[Q[id].c]-sum[id]);
		}
	}
	EOR(G,i,x){
		int v=G.to[i];
		if(v==f)continue;
		cnt1[bel[v]]++;
		sum1[bel[v]]+=G.len[i];
		redfs(v,x);
		sum1[bel[v]]-=G.len[i];
		cnt1[bel[v]]--;
	}
}
int main(){
	G.clear();
	sf("%d%d",&n,&q);
	FOR(i,1,n-1){
		int x,y,c,d;
		sf("%d%d%d%d",&x,&y,&c,&d);
		G.add(x,y,c,d),G.add(y,x,c,d);
	}
	dfs(1,0);
	top_dfs(1,0,1);
	FOR(i,1,q){
		sf("%d%d%d%d",&Q[i].c,&Q[i].d,&Q[i].x,&Q[i].y);
		int lca=LCA(Q[i].x,Q[i].y);
		ans[i]=dis[Q[i].x]+dis[Q[i].y]-2*dis[lca];
		mark[lca].pb(i);
		mark[Q[i].x].pb(-i);
		mark[Q[i].y].pb(-i);
	}
	redfs(1,0);
	FOR(i,1,q)pf("%lld\n",ans[i]);
	return 0;
}