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 <vector>
#include <utility>
#include <map>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost, color;
	edge(llint a, llint b, llint c){
		to = a, cost = c, color = b;
	}
};

llint n, Q;
map<P, P> mp;
vector<edge> G[100005];
vector<int> vec[100005];
llint x[100005], y[100005], u[100005], v[100005];

int Prev[100005][17];
llint depth[100005], dist[100005];

int getLCA(int u, int v){
	int x = u, y = v;
	if(depth[y] > depth[x]) swap(x, y);
	
	for(int i = 16; i >= 0; i--){
		if(depth[x] - (1<<i) >= depth[y]) x = Prev[x][i];
	}
	if(x == y) return x;
	for(int i = 16; i >= 0; i--){
		if(Prev[x][i] != Prev[y][i]){
			x = Prev[x][i];
			y = Prev[y][i];
		}
	}
	x = Prev[x][0];
	return x;
}

void dfs(int v, int p, int dep, llint dis)
{
	Prev[v][0] = p;
	depth[v] = dep, dist[v] = dis;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == p) continue;
		dfs(G[v][i].to, v, dep+1, dis + G[v][i].cost);
	}
}

llint num[100005], sum[100005];
void dfs2(int v, int p)
{
	for(int i = 0; i < vec[v].size(); i++){
		llint c = vec[v][i];
		mp[make_pair(v, c)] = make_pair(num[c], sum[c]);
		//cout << v << " " << c << " " << num[v] << " " << sum[v] << endl;
	}
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == p) continue;
		num[G[v][i].color]++;
		sum[G[v][i].color] += G[v][i].cost;
		dfs2(G[v][i].to, v);
		num[G[v][i].color]--;
		sum[G[v][i].color] -= G[v][i].cost;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> Q;
	for(int i = 1; i <= n-1; i++){
		llint u, v, c, d;
		cin >> u >> v >> c >> d;
		G[u].push_back(edge(v, c, d));
		G[v].push_back(edge(u, c, d));
	}
	dfs(1, -1, 0, 0);
	
	for(int i = 1; i < 17; i++){
		for(int j = 1; j <= n; j++){
			Prev[j][i] = Prev[Prev[j][i-1]][i-1];
		}
	}
	for(int i = 0; i < Q; i++){
		cin >> x[i] >> y[i] >> u[i] >> v[i];
		vec[u[i]].push_back(x[i]);
		vec[v[i]].push_back(x[i]);
		vec[getLCA(u[i], v[i])].push_back(x[i]);
		//cout << u[i] << " " << v[i] << " " << getLCA(u[i], v[i]) << endl;
	}
	dfs2(1, -1);
	
	for(int i = 0; i < Q; i++){
		llint lca = getLCA(u[i], v[i]);
		llint ans = dist[u[i]] + dist[v[i]] - 2*dist[lca];
		llint cnt = mp[make_pair(u[i], x[i])].first + mp[make_pair(v[i], x[i])].first - 2*mp[make_pair(lca, x[i])].first;
		llint sum = mp[make_pair(u[i], x[i])].second + mp[make_pair(v[i], x[i])].second - 2*mp[make_pair(lca, x[i])].second;
		//cout << cnt << " " << sum << endl;
		ans -= sum;
		ans += cnt * y[i];
		cout << ans << "\n";
	}
	flush(cout);
	
	return 0;
}