#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



struct LCA {
	static const int MAX = 1 << 18;
	vector<int>seg;
	vector<int>idx;
	void st(int p, int v) {
		p += MAX - 1;
		seg[p] = v;
		idx[p] = p - MAX + 1;
		while (p > 0) {
			p = (p - 1) / 2;
			seg[p] = min(seg[2 * p + 1], seg[2 * p + 2]);
			if (seg[2 * p + 1] > seg[2 * p + 2])idx[p] = idx[2 * p + 2];
			else if (seg[2 * p + 1] < seg[2 * p + 2])idx[p] = idx[2 * p + 1];
			else idx[p] = min(idx[2 * p + 1], idx[2 * p + 2]);
		}
	}
	pair<int, int> query(int l, int r, int a, int b, int k) {
		if (r <= a || b <= l)return { INT_MAX / 2,INT_MAX / 2 };
		if (l <= a && b <= r)return { seg[k],idx[k] };
		int m = (a + b) / 2;
		auto p1 = query(l, r, a, m, 2 * k + 1);
		auto p2 = query(l, r, m, b, 2 * k + 2);
		if (p1.first < p2.first) return p1;
		else if (p1.first > p2.first)return p2;
		else return { p1.first,min(p1.second,p2.second) };
	}

	void seginit() {
		seg.resize(2 * MAX);
		idx.resize(2 * MAX);
		for (int i = 0; i < 2 * MAX; i++)seg[i] = INT_MAX / 2;
	}
	//[l,r]
	int get(int l, int r) {
		return query(l, r + 1, 0, MAX, 0).first;
	}
	int getidx(int l, int r) {
		return query(l, r + 1, 0, MAX, 0).second;
	}

	vector<int>vs;
	vector<int>id;
	int k = 0;
	void lcadfs(int now, int p, int d, vector<int>edges[]) {
		vs[k] = now;
		id[now] = k;
		st(k++, d);
		fore(x, edges[now]) {
			if (x != p) {
				lcadfs(x, now, d + 1, edges);
				vs[k] = now;
				st(k++, d);
			}
		}
	}

	void lcainit(int n, int root, vector<int>edges[]) {
		vs.resize(2 * n);
		id.resize(n);
		seginit();
		for (int i = 0; i < n; i++)st(i, 0);
		int k = 0;
		lcadfs(root, -1, 0, edges);
	}

	int calc_lca(int x, int y) {
		return vs[getidx(min(id[x], id[y]), max(id[x], id[y]))];
	}
};

vector<int>edges[101010];
vector<vector<int>>edges2[101010];
vector<int>need[101010];
int X[101010], Y[101010], U[101010], V[101010],L[101010];
int dist[101010];
map<int, int>sum[101010], cnt[101010];
int cursum[101010], curcnt[101010];

void dfs(int now,int p) {
	fore(x, need[now]) {
		sum[now][x] = cursum[x];
		cnt[now][x] = curcnt[x];
	}
	fore(x,edges2[now]) {
		int to = x[0];
		int cost = x[1];
		int col = x[2];
		if (to != p) {
			cursum[col] += cost;
			curcnt[col]++;
			dist[to] = dist[now] + cost;
			dfs(to, now);
			cursum[col] -= cost;
			curcnt[col]--;
		}
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--, b--, c--;
		edges[a].pb(b);
		edges[b].pb(a);
		edges2[a].pb({b,d,c});
		edges2[b].pb({a,d,c});
	}
	LCA lca;
	lca.lcainit(n,0,edges);

	for (int i = 0; i < q; i++) {
		cin >> X[i] >> Y[i] >> U[i] >> V[i];
		X[i]--, U[i]--, V[i]--;
		L[i] = lca.calc_lca(U[i], V[i]);
		need[U[i]].pb(X[i]);
		need[V[i]].pb(X[i]);
		need[L[i]].pb(X[i]);
	}
	dfs(0, -1);
	for (int i = 0; i < q; i++) {
		int distu = dist[U[i]] - sum[U[i]][X[i]] + Y[i] * cnt[U[i]][X[i]];
		int distv = dist[V[i]] - sum[V[i]][X[i]] + Y[i] * cnt[V[i]][X[i]];
		int distl = dist[L[i]] - sum[L[i]][X[i]] + Y[i] * cnt[L[i]][X[i]];
		puts(distu+distv - 2*distl);
	}
	
	return 0;
}

Measured memory_bytes: 70964