#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<random>
#include<ctime>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,sse4,popcnt")

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;

const int N = 150000 + 2, inf = 1e9 + 100;
const ll llinf = 1e18 + 1000;

int n, m, sz[N], h[N], pr[N], tin[N], tout[N], ind[N], path[N], ans[N], timer = 0;
vector<int> g[N], a[N];
int c[N];

void dfs1(int v, int p) {
	sz[v] = 1;
	for (int i = 0; i < g[v].size(); ++i) {
		int to = g[v][i];
		if (to == p) {
			swap(g[v][i], g[v].back());
			g[v].pop_back();
			--i;
			continue;
		}
		h[to] = h[v] + 1;
		dfs1(to, v);
		pr[to] = v;
		sz[v] += sz[to];
		if (sz[to] > sz[g[v][0]]) swap(g[v][0], g[v][i]);
	}
}
void dfs2(int v, int p) {
	path[v] = p;
	ind[timer] = v;
	tin[v] = timer++;
	for (auto to : g[v]) {
		dfs2(to, to == g[v][0] ? p : to);
	}
	tout[v] = timer;
}
void build_path(int x, int y, int ind, ll t) {
	while (tin[y] < tin[x] || tin[y] >= tout[x]) {
		a[ind].push_back(x);
		x = pr[x];
	}
	vector<int> a1;
	while (1) {
		a1.push_back(y);
		if (y == x) break;
		y = pr[y];
	}
	reverse(all(a1));
	for (auto i : a1) a[ind].push_back(i);
}

vector<int> solve(vector<pair<int, int>> _r, vector<ll> _d, vector<int> _s, vector<int> _t, vector<bool> _ty) {
	n = _r.size() + 1;
	m = _d.size();
	for (int i = 0; i + 1 < n; ++i) {
		g[_r[i].first].push_back(_r[i].second);
		g[_r[i].second].push_back(_r[i].first);
	}
	dfs1(0, -1);
	dfs2(0, 0);
	for (int i = 0; i < m; ++i) {
		build_path(_s[i], _t[i], i, _d[i]);
		c[i] = _ty[i];
	}
	for (int it = 0; it < n; ++it) {
		vector<bool> used(n);
		for (int i = 0; i < m; ++i) {
			if (a[i].size() > it && c[i]) {
				used[a[i][it]] = 1;
			}
		}
		for (int i = 0; i < m; ++i) {
			if (a[i].size() > it && used[a[i][it]]) {
				c[i] = 1;
				++ans[i];
			}
		}
	}
	vector<int> ans1(m);
	for (int i = 0; i < m; ++i) {
		ans1[i] = ans[i];
	}
	return ans1;
}

void solve() {
	int _n, _m;
	cin >> _n >> _m;
	vector<pair<int, int>> _r(_n - 1);
	for (auto& p : _r) {
		cin >> p.first >> p.second;
	}
	vector<ll> _d(_m);
	vector<int> _s(_m);
	vector<int> _t(_m);
	vector<bool> _ty(_m);
	for (int i = 0; i < _m; ++i) {
		cin >> _d[i] >> _s[i] >> _t[i];
		int x;
		cin >> x;
		_ty[i] = x;
	}
	vector<int> _ans = solve(_r, _d, _s, _t, _ty);
	for (auto i : _ans) {
		cout << i << ' ';
	}
}

/*signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
		cout.flush();
	}
	return 0;
}*/