#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
#define endl '\n'

std::vector<int> solve(
    std::vector<std::pair<int, int>> edge,
    std::vector<long long> d,
    std::vector<int> s,
    std::vector<int> f,
    std::vector<bool> c
) {
    int n = edge.size() + 1;
    vector <vector <int>> g(n + 1);

    for(int i = 0;i < n - 1;i++){
        g[edge[i].ff].pb(edge[i].ss);
        g[edge[i].ss].pb(edge[i].ff);
    }

    int m = d.size();

    vector <vector <int>> child(m , vector <int> (n + 1, -1));

    for(int i = 0;i < m;i++){
        vector <int> par(n + 1, -1);

        queue <int> q;

        q.push(s[i]);
        par[s[i]] = s[i];

        int den = d[i];

        while(!q.empty()){
            int x = q.front();
            q.pop();

            for(int u : g[x]){
                if(par[u] == -1){
                    par[u] = x;
                    q.push(u);
                }
            }
        }
        while(par[t[i]] != t[i]){
            child[i][par[t[i]]] = t[i];
        }
    }

    vector <int> ans;

    for(int den = 1;den <= n;den++){
        vector <int> inf(n);
        for(int i = 0;i < m;i++){
            if(s[i] == -1) continue;
            if(d[i] == den && c[i] == 1){
                inf[s[i]] = 1;
            }
        }
        for(int i = 0;i < n;i++){
            if(d[i] == den){
                c[i] = max(inf[s[i]] , c[i]);
                s[i] = child[i][s[i]];
                d[i]++;
            }
        }
        for(int i = 0;i < n;i++){
            ans[i] += c[i];
        }
    }

    return ans;

}
signed main() {
    int n, m;

    std::cin >> n;
    std::cin >> m;

    std::vector<std::pair<int, int>> edges = {};
    std::vector<long long> day;
    std::vector<int> start;
    std::vector<int> target;
    std::vector<bool> infected;

    for (int i = 0; i < n - 1; i++) {
        int u, v;
        std::cin >> u >> v;
        edges.emplace_back(u, v);
    }

    for (int i = 0; i < m; i++) {
        long long _d, _s, _t, _i;
        std::cin >> _d >> _s >> _t >> _i;
        day.push_back(_d);
        start.push_back(_s);
        target.push_back(_t);
        infected.push_back(_i);
    }

    vector <int> ans = solve(edges, day, start, target, infected);
    for (int  it : ans) {
        std::cout << it << std::endl;
    }

    return 0;
}
