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<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
#define int long long 
struct node{int to,nxt,cost,col;}sq[200200];
int all=0,head[100100];
int n,q,dep[100100],fa[100100][20],cnt[100100];
struct qnode{int col,len,x,id;};
vector<qnode> ask[100100];
ll ans[100100],dis[100100],cdis[100100];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void add(int u,int v,int col,int w)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];sq[all].col=col;sq[all].cost=w;head[u]=all;
}

void dfs(int u,int fu)
{
	dep[u]=dep[fu]+1;fa[u][0]=fu;
	rep(i,1,19)
		fa[u][i]=fa[fa[u][i-1]][i-1];
	for (int i=head[u];i;i=sq[i].nxt)
	{
		int v=sq[i].to;
		if (v==fu) continue;
		dis[v]=dis[u]+sq[i].cost;
		dfs(v,u);
	}
}

int LCA(int u,int v)
{
	if (dep[u]<dep[v]) swap(u,v);
	int tmp=dep[u]-dep[v];
	per(i,19,0)
		if ((tmp>>i)&1) u=fa[u][i];
	if (u==v) return u;
	per(i,19,0)
		if (fa[u][i]!=fa[v][i])
		{
			u=fa[u][i];v=fa[v][i];
		}
	return fa[u][0];
}

void dfs1(int u,int fu)
{
	int len=ask[u].size();
	rep(i,0,len-1)
	{
		ans[ask[u][i].id]+=1ll*ask[u][i].x*(dis[u]-cdis[ask[u][i].col]+1ll*ask[u][i].len*cnt[ask[u][i].col]);
	}
	for (int i=head[u];i;i=sq[i].nxt)
	{
		int v=sq[i].to;
		if (v==fu) continue;
		cnt[sq[i].col]++;cdis[sq[i].col]+=sq[i].cost;
		dfs1(v,u);
		cnt[sq[i].col]--;cdis[sq[i].col]-=sq[i].cost;
	}
}

signed main()
{
	n=read();q=read();
	rep(i,1,n-1)
	{
		int u=read(),v=read(),col=read(),w=read();
		add(u,v,col,w);add(v,u,col,w);
	}
	dfs(1,0);
	rep(i,1,q)
	{
		int col=read(),w=read(),u=read(),v=read(),l=LCA(u,v);
		ask[u].push_back((qnode){col,w,1,i});
		ask[v].push_back((qnode){col,w,1,i});
		ask[l].push_back((qnode){col,w,-2,i});
	}
	dfs1(1,0);
	rep(i,1,q) printf("%lld\n",ans[i]);
	return 0;
}