# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost,col; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000],d[210000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL col_n[200000], col_c[200000];
struct query {
	LL v, u, cost, col,index;
};
query qu[200000];
class LCA {
public:
	int n = 0;
	int log2_n = 0;
	int type_size = 0; //森の個数
	vector<std::vector<int>> parent;
	vector<int> depth, type, root;
	//typeは森の番号,rootは森の根
	LCA() {}

	LCA(const vector<vector<Edge>> &g)
		: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n), type(n) {
		for (int i = 0; i < n; i++) {
			if (depth[i] == 0) {
				root.push_back(i);
				dfs(g, i, -1, 0, type_size++);
			}
		}
		for (int k = 0; k + 1 < log2_n; k++) {
			for (int v = 0; v < (int)g.size(); v++) {
				if (parent[k][v] < 0)
					parent[k + 1][v] = -1;
				else
					parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}

	void dfs(const vector<vector<Edge>> &g, int v, int p, int d, int t) {
		parent[0][v] = p;
		depth[v] = d;
		type[v] = t;
		for (auto &e : g[v]) {
			if (e.to != p) dfs(g, e.to, v, d + 1, t);
		}
	}

	int get(int u, int v) {
		if (type[u] != type[v])return -1;
		if (depth[u] > depth[v]) std::swap(u, v);
		for (int k = 0; k < log2_n; k++) {
			if ((depth[v] - depth[u]) >> k & 1) {
				v = parent[k][v];
			}
		}
		if (u == v) return u;
		for (int k = log2_n - 1; k >= 0; k--) {
			if (parent[k][u] != parent[k][v]) {
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}
};
void dfs(LL cur, LL par) {
	for (auto it = ma.lower_bound(Pll(cur, 0)); it->first.first == cur&&it!=ma.end(); it++) {
		if (it == ma.end())break;
		it->second = Pll(col_n[it->first.second], col_c[it->first.second]);
	}
	rep(i, g[cur].size()) {
		auto e = g[cur][i];
		if (e.to == par)continue;
		col_n[e.col]++;
		col_c[e.col] += e.cost;
		d[e.to] = d[cur] + e.cost;
		dfs(e.to, cur);
		col_n[e.col]--;
		col_c[e.col] -= e.cost;
	}
}
int main() {
	cin >> n >> q;
	g.resize(n);
	rep(i, n - 1) {
		LL x, y, z, w;
		cin >> x >> y >> z >> w;
		x--, y--, z--;
		g[x].push_back(Edge{ y,w,z });
		g[y].push_back(Edge{ x,w,z });
	}
	ma[Pll(INF, 0)] = Pll(0, 0);
	LCA lca(g);
	rep(i, q) {
		LL x, y, z, w;
		cin >> z >> w >> x >> y;
		x--, y--, z--;
		qu[i] = query{ x,y,w,z,i };
		ma[Pll(x, z)] = Pll(-1, -1);
		ma[Pll(y, z)] = Pll(-1, -1);
		ma[Pll(lca.get(x, y), z)] = Pll(-1, -1);
	}
	dfs(0,-1);
	rep(i, q) {
		LL num = ma[Pll(qu[i].u, qu[i].col)].first + ma[Pll(qu[i].v, qu[i].col)].first -
			ma[Pll(lca.get(qu[i].u, qu[i].v), qu[i].col)].first * 2,
			cos= ma[Pll(qu[i].u, qu[i].col)].second + ma[Pll(qu[i].v, qu[i].col)].second -
				ma[Pll(lca.get(qu[i].u, qu[i].v), qu[i].col)].second * 2;
		cout<<d[qu[i].u]+ d[qu[i].v]- d[lca.get(qu[i].u,qu[i].v)]*2-cos+num*qu[i].cost<<endl;
	}
	return 0;
}


Measured memory_bytes: 48308