#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
vector<int> g[N];
int tin[N], tout[N];
int up[20][N];
int t;
int depth[N];
void precalc (int v, int p = -1) {
    tin[v] = t++;
    up[0][v] = p;
    depth[v] = depth[p] + 1;
    for (int l = 1; l < 20; ++l) up[l][v] = up[l - 1][up[l - 1][v]];
    for (auto to : g[v]) {
        if (to != p) precalc (to, v);
    }
    tout[v] = t;
}
bool is_anc (int u, int v) {
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int lca (int u, int v) {
    if (is_anc (u, v)) return u;
    if (is_anc (v, u)) return v;
    for (int l = 19; l >= 0; --l) {
        if (!is_anc (up[l][u], v)) u = up[l][u];
    }
    return up[0][u];
}
int dist (int u, int v) {
    return depth[u] + depth[v] - 2 * depth[lca (u, v)] + 1;
}
std::vector<int> solve(
std::vector<std::pair<int, int>> R,
std::vector<long long> D,
std::vector<int> S,
std::vector<int> T,
std::vector<bool> I) {
    int n = (int)R.size() + 1, m = (int)I.size();
    for (auto [u, v] : R) g[u].push_back (v), g[v].push_back (u);
    vector<bool> was (n + 1);
    for (int i = 0; i < m; ++i) {
        if (I[i]) was[S[i]] = 1;
    }
    precalc (0);
    vector<int> ans;
    for (int i = 0; i < m; ++i) {
        if (I[i]) ans.push_back(dist (S[i], T[i]));
        else ans.push_back(0);
    }
    return ans;
};

#ifdef LOCAL
//#include "infection.h"
#include <vector>
#include <iostream>

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);
    }

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

    return 0;
}

#endif // LOCAL
