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>

using namespace std;

#define REP(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

int n, k;
const int SIZE = 100005;

int first[SIZE], ecnt;
struct Edge {
	int v, nxt, dis, c;
} edge[SIZE << 1];
void Add_Edge (int u, int v, int c, int dis) {
	++ecnt;
	edge[ecnt].v = v;
	edge[ecnt].dis = dis;
	edge[ecnt].c = c;
	edge[ecnt].nxt = first[u];
	first[u] = ecnt;
}

int tree[SIZE], Lson[SIZE * 18], Rson[SIZE * 18], cnt[SIZE * 18], node_cnt;
long long tot[SIZE * 18];

void Insert (int& rt, int od, int L, int R, int x, int d) {
	rt = ++node_cnt;
	Lson[rt] = Lson[od];
	Rson[rt] = Rson[od];
	if (L == R) {
		cnt[rt] = cnt[od] + 1;
		tot[rt] = tot[od] + d;
		return;
	}
	int mid = L + R >> 1;
	if (x <= mid) Insert (Lson[rt], Lson[od], L, mid, x, d);
	else Insert (Rson[rt], Rson[od], mid + 1, R, x, d);
}

long long y;
long long Query (int rt, int L, int R, int x) {
	if (L == R) return cnt[rt] * y - tot[rt];
	int mid = L + R >> 1;
	if (x <= mid) return Query (Lson[rt], L, mid, x);
	else return Query (Rson[rt], mid + 1, R, x);
}

long long dis[SIZE];
int dp[SIZE][18], dep[SIZE];

void DFS (int u, int fa) {
	EREP (i, u) {
		Edge& e = edge[i];
		if (e.v == fa) continue;
		dis[e.v] = dis[u] + e.dis;
		dep[e.v] = dep[u] + 1;
		dp[e.v][0] = u;
		Insert(tree[e.v], tree[u], 1, n - 1, e.c, e.dis);
		DFS (e.v, u);
	}
}

int Up (int x, int step) {
	REP (i, 0, 17) if (1 << i & step)
		x = dp[x][i];
	return x;
}

int LCA (int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	x = Up (x, dep[x] - dep[y]);
	if (x == y) return x;
	DREP (i, 17, 0) if (dp[x][i] != dp[y][i])
		x = dp[x][i], y = dp[y][i];
	return dp[x][0];
}

int main () {
	scanf ("%d%d", &n, &k);

	REP (i, 1, n - 1) {
		int u, v, c, d;
		scanf ("%d%d%d%d", &u, &v, &c, &d);
		Add_Edge (u, v, c, d);
		Add_Edge (v, u, c, d);
	}

	DFS (1, 0);

	REP (i, 1, 17) REP (j, 1, n)
		dp[j][i] = dp[dp[j][i - 1]][i - 1];

	REP (i, 1, k) {
		int x, u, v;
		scanf ("%d%lld%d%d", &x, &y, &u, &v);
		int lca = LCA (u, v);
		printf ("%lld\n", dis[u] + dis[v] + Query (tree[u], 1, n - 1, x) + Query (tree[v], 1, n - 1, x) - 2 * dis[lca] - 2 * Query (tree[lca], 1, n - 1, x));
	}

	return 0;
}